Connection resets after a minute,.



Hello All.

What I am doing is after my class below connects to the server. I
disconnect the network cable from the computer. If I reconnect the network
cable after about a minute or so all is well and the client works correctly.

However if I remove the network cable but this time send some data like a OK
message using the writeMessage method all works, but after a minute the
replyRead = dataReader.readLine(); fails with a null, with results in a
connection reset message. The network cable is still disconnected at this
time.

I think that the print writer has sent the information to the TCP buffer, as
the system can not do anything and is waiting.
Is there a timer I can increase ?

What I am trying to achieve is that the client should should work over a
VPN, I get this connection reset after a while periodically. I guess the
VPN is very hostile.

The TIMEOUT value is set to 2 minutes.

many thianks for your help.
Kalpesh Modha

class dataWorker extends Thread
{
// server connection stuff
private Socket dataConnection = null;
private BufferedReader dataReader = null;
private PrintWriter dataWriter = null;

private String lastMessageSent = ""; // last message sent

// thread bit
public void run()
{
String replyRead = "";
try {

// make a connection to the master server.
dataConnection = new
Socket(setting.getDataServerAddress(),setting.getDataServerPort());
dataReader = new BufferedReader(new
InputStreamReader(dataConnection.getInputStream()));
dataWriter = new PrintWriter(dataConnection.getOutputStream(),true);

//dataConnection.setSoLinger(true,LINGER);
dataConnection.setSoTimeout(TIMEOUT);
System.out.println("Data TImeout: " + dataConnection.getSoTimeout());
System.out.println("Data linger value: " + dataConnection.getSoLinger());

} catch(UnknownHostException e)
{
writeLogEntry(ERROR_MESSAGE + "Unknown Host Data Worker: " +
e.getMessage());
errorOccured(ERROR_MESSAGE + "Unknown Host Data Worker: " +
e.getMessage());
} catch(IOException e)
{
writeLogEntry(ERROR_MESSAGE + "Error Data Worker: " + e.getMessage());
errorOccured(ERROR_MESSAGE + "Error Data Worker: " + e.getMessage());
}


try {
// greeting
dataReader.readLine();
} catch(IOException e)
{
writeLogEntry("Failed to get greeting data:"; + e.getMessage());
writeLogEntry("DATA Cause SOURCE: " + e.getCause());
e.printStackTrace();
}

// this will set our name
writeDataMessage(COMMAND_SETNAME + " " + setting.getLogin());

// write entry we have logged in correctly
writeReason("Log Successful","");

// send the command to get the dialling codes.
writeDataMessage(COMMAND_PREFIX);

try {
while (true)
{
/*** this breaks with a null. ***/
replyRead = dataReader.readLine();

/*** other code removed ***/

}
}
catch(IOException ioe)
{
writeLogEntry("IOException in Data:"; + ioe.getMessage());
writeLogEntry("DATA Cause SOURCE: " + ioe.getCause());
ioe.printStackTrace();
}
catch(Exception e)
{
writeLogEntry("Exception in Data:"; + e.getMessage());
writeLogEntry("DATA Cause SOURCE: " + e.getCause());
e.printStackTrace();
} finally {
try {
dataReader.close();
} catch(IOException I ){}
finally{
dataReader = null;
}

try {
dataWriter.close();
} catch(Exception i) {}
finally {
dataWriter = null;
}

try {
dataConnection.close();
} catch(IOException i) {}
finally{
dataConnection = null;
}
}

}

public void writeMessage(String temp)
{
lastMessageSent = temp;//save the last message
dataWriter.println(temp);
}
// end of dataWorker class
}


.



Relevant Pages

  • RE: Windows Server 2003 GPM/Windows 2000 TS GPO issue
    ... > Framework, Tarantella Secure Global Desktop Terminal Server Edition, Citrix ... rather than simply disconnect (we have an issue with multiple ... >> Policy Setting ...
    (microsoft.public.windows.terminal_services)
  • RE: Problems with Remote Desktop Connction to SBS
    ... the office and connecting over a VPN and on the server itself (you can ... You mentioned "Disconnect, but leave session running", I have ... As Sarah said, how did you disconnect? ... Please type the full error message word by word to the Newsgroup, ...
    (microsoft.public.windows.server.sbs)
  • Event ID: 12061
    ... >timed out and disconnected by the server. ... The IP address of the Macintosh workstation is ... The events security log reports the following when the ... The disconnect occurs when the machines are idle and ...
    (microsoft.public.win2000.macintosh)
  • Re: Account keeps locking out
    ... disconnect the mapping manually, also the printer (which was setup using the ... Does the user have manually mapped network drives? ... the server kept on locking him out. ... Client accesses the internet via the server, ...
    (microsoft.public.windows.server.sbs)
  • Re: Account keeps locking out
    ... disconnect the mapping manually, also the printer (which was setup using ... and hen I remapped the printer and the drives, ... the server kept on locking him out. ... Client accesses the internet via the server, ...
    (microsoft.public.windows.server.sbs)