java - ObjectInputStream Blocking socket external ip madness -


when initialize objectinputstreams, after have initialized , flushed objectoutputstreams, this:

client:

java.net.sockettimeoutexception: read timed out @ java.net.socketinputstream.socketread0(native method) @ java.net.socketinputstream.read(unknown source) @ java.net.socketinputstream.read(unknown source) @ java.io.objectinputstream$peekinputstream.read(unknown source) @ java.io.objectinputstream$peekinputstream.readfully(unknown source) @ java.io.objectinputstream$blockdatainputstream.readshort(unknown source) @ java.io.objectinputstream.readstreamheader(unknown source) @ java.io.objectinputstream.(unknown source) @ start.refreshchangelog(start.java:87) @ start$2.windowopened(start.java:234) @ java.awt.awteventmulticaster.windowopened(unknown source) @ java.awt.window.processwindowevent(unknown source) @ javax.swing.jframe.processwindowevent(unknown source) @ java.awt.window.processevent(unknown source) @ java.awt.component.dispatcheventimpl(unknown source) @ java.awt.container.dispatcheventimpl(unknown source) @ java.awt.window.dispatcheventimpl(unknown source) @ java.awt.component.dispatchevent(unknown source) @ java.awt.eventqueue.dispatcheventimpl(unknown source) @ java.awt.eventqueue.access$200(unknown source) @ java.awt.eventqueue$3.run(unknown source) @ java.awt.eventqueue$3.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.awt.eventqueue$4.run(unknown source) @ java.awt.eventqueue$4.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.awt.eventqueue.dispatchevent(unknown source) @ java.awt.eventdispatchthread.pumponeeventforfilters(unknown source) @ java.awt.eventdispatchthread.pumpeventsforfilter(unknown source) @ java.awt.eventdispatchthread.pumpeventsforhierarchy(unknown source) @ java.awt.eventdispatchthread.pumpevents(unknown source) @ java.awt.eventdispatchthread.pumpevents(unknown source) @ java.awt.eventdispatchthread.run(unknown source)

server:

java.net.socketexception: connection reset @ java.net.socketinputstream.read(unknown source) @ java.net.socketinputstream.read(unknown source) @ java.io.objectinputstream$peekinputstream.read(unknown source) @ java.io.objectinputstream$peekinputstream.readfully(unknown source) @ java.io.objectinputstream$blockdatainputstream.readshort(unknown source) @ java.io.objectinputstream.readstreamheader(unknown source) @ java.io.objectinputstream.(unknown source) @ client.(client.java:27) @ threadaccept.run(threadaccept.java:23)

and client code:

public void refreshchangelog() {     socket logsocket = null;     objectinputstream input = null;     objectoutputstream output = null;     try {         logsocket = new socket(inetaddress.getbyname(server), 21992);         logsocket.setsotimeout(0);         output = new objectoutputstream(logsocket.getoutputstream());         output.flush();         input = new objectinputstream(logsocket.getinputstream());         output.writeobject("type:changelog");         output.flush();         object o = input.readobject();         while (o instanceof string && !((string) o).equals("done")) {             string msg = (string) o;             int index = msg.indexof("|");             if (index > -1) {                 changelogmap.put(msg.substring(0, index), msg.substring(index + 1));                 changeloglist.additem(msg.substring(0, index));             }             o = input.readobject();         }     }catch (exception e) {         e.printstacktrace();         loadlocalchangelog();     }     if (changeloglist.getitemcount() > 0) {         changeloglist.setselectedindex(0);         file changelog = new file(path + "changelog");         if (!changelog.exists() || !changelog.isdirectory()) {             changelog.mkdirs();         }         (string key : changelogmap.keyset()) {             file changef = new file(changelog, key + ".txt");             if (!changef.exists()) {                 try {                     changef.createnewfile();                 }catch (ioexception e) {                     e.printstacktrace();                 }             }             if (changef.exists()) {                 printwriter writer;                 try {                     writer = new printwriter(changef);                     writer.write(changelogmap.get(key));                 }catch (ioexception e) {                     e.printstacktrace();                 }             }         }     }     try {         if (output != null) {             output.close();             output = null;         }         if (input != null) {             input.close();             input = null;         }         if (logsocket != null) {             logsocket.close();             logsocket = null;         }     }catch (ioexception e1) {         e1.printstacktrace();     } }` 

and server code:

socket = new serversocket(21992);         new client.threadupdatelobby();         while (start.frame != null && socket != null && !socket.isclosed()) {             socket clientsocket = socket.accept();             clientsocket.setsotimeout(0);             client client = new client(clientsocket);             if (client.isvalid) {                 synchronized (clients) {                     clients.add(client);                 }             }             thread.sleep(50l);         }` 

more server code:

this.socket = socket;     try {         this.socket = socket;         output = new objectoutputstream(socket.getoutputstream());         output.flush();         input = new objectinputstream(socket.getinputstream());         listener = new threadlisten(this, input);         isvalid = true;     }catch (exception e) {         e.printstacktrace();         try {             if (output != null) {                 output.close();                 output = null;             }             if (input != null) {                 input.close();                 input = null;             }             if (socket != null) {                 socket.close();                 this.socket = null;             }         }catch (ioexception e1) {             e1.printstacktrace();         }         isvalid = false;     }` 

i've been @ loss, apparently header isn't flushing? therefor inputstream sits , waits. problem appears client side. also, happens if use external network ip(98.232.202.119), no problems if use "127.0.0.1" or "192.168.2.50" ports forwarded, , tested them online.

i know question died, google's sake, fix this, check if client's external ip matches server's ip, , if does, use local address. causes it? it's router. in models, wan security prevents local computers acting remote computers. don't see security problem this, apparently, router companies do. tried call company , have wan security disabled, find out, it's not possible.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -