Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Timeout Exception (Socket Timeout exception in Eclipse Plug-in)
Timeout Exception [message #1021197] Tue, 19 March 2013 12:35 Go to next message
Eclipse UserFriend
Hi, I have developed a plug-in which communicates to Server using TCP/IP. I am getting the data perfectly, the problem is after reading all the data SocketTimeout exception is raised and going to catch block.
I have increased the SocketTimeout value too, but still no use.
Can any one help me? I am placing Trace of the exception.

java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.read(Unknown Source)
at com.infotech.debugger.util.ClientCommunication.startCommunication(ClientCommunication.java:89)
at com.infotech.debugger.dialog.StartConditionsDialog.startCommunication(StartConditionsDialog.java:894)
at com.infotech.debugger.dialog.StartConditionsDialog.access$9(StartConditionsDialog.java:817)
at com.infotech.debugger.dialog.StartConditionsDialog$7.widgetSelected(StartConditionsDialog.java:501)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at com.infotech.debugger.actions.StartDebugger.execute(StartDebugger.java:54)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:229)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:210)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:131)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:171)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:851)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:744)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:728)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:667)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

[Updated on: Tue, 19 March 2013 12:42] by Moderator

Re: Timeout Exception [message #1021221 is a reply to message #1021197] Tue, 19 March 2013 13:23 Go to previous messageGo to next message
Eclipse UserFriend
This really isn't an appropriate question for the JDT forums. A general Java programming forum would be a better place to ask. That being said, my guess is that you are continuing to issue reads after all the data has been received. Your code needs to recognize the fact that the data has been read and stop calling the read method on the Reader/Socket.
Re: Timeout Exception [message #1021511 is a reply to message #1021221] Wed, 20 March 2013 04:55 Go to previous messageGo to next message
Eclipse UserFriend
the following is the code i have written, Some one can identify the problem in the below code for TimeoutException.

try {
if(echoSocket == null)
echoSocket = new Socket(hostAddress, serverPort);

if(echoSocket.getInetAddress() != null)
{
out = new PrintWriter(echoSocket.getOutputStream(), true);
String userInput=command.concat(" \r") ;
out.println(userInput);
out.flush();
echoSocket.setSoTimeout(timeout);
br = new BufferedReader(new InputStreamReader(echoSocket.getInputStream()));
responseLine = "";

while((value = br.read()) != -1)
{
char c = (char)value;
responseLine = responseLine + c;
}

}
}

[Updated on: Wed, 20 March 2013 05:35] by Moderator

Re: Timeout Exception [message #1021690 is a reply to message #1021511] Wed, 20 March 2013 10:19 Go to previous message
Eclipse UserFriend
You need to spend some time studying how stream IO works. Reads on streams will block if there is no data as long as the stream remains open.

Again, I would emphasize that this forum isn't for general Java programming questions. Your questions are more suited for a general Java programming forum such as Stack Overflow.
Previous Topic:How to access to an IResource before it is modified
Next Topic:bad contrast in context window
Goto Forum:
  


Current Time: Tue Jul 22 18:09:09 EDT 2025

Powered by FUDForum. Page generated in 0.04300 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top