B4J Question Reason of socket reset.

Discussion in 'B4J Questions' started by HARRY, Jul 23, 2015.

  1. HARRY

    HARRY Active Member Licensed User

    I have posted this question in the wrong section; it is a B4J question. Please move it to that section.

    Hi,

    I have a strange problem using asyncstreams.

    My program is a server program running on a raspberry, newest version . It accepts messages arriving from sensors with some intervals via the USB port using asyncsteamtext.

    It runs for some time accepting messages and the suddenly it stops with the following error information:

    java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:189)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at java.net.SocketInputStream.read(SocketInputStream.java:107)
    at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:184)
    at java.lang.Thread.run(Thread.java:744)
    error: (SocketException) java.net.SocketException: Connection reset

    Sometimes it runs only for some minutes, sometimes it runs for an hour.

    The program is also listening to two other streams, a second asyncstreamtext and one asyncstreamobject, but on these streams nothing happens. This error occurs both in debug mode and in release mode.

    What can be the reason for this error and how can I get more information on the reason?

    Harry
     
    Last edited: Jul 23, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should expect network connections to break from time to time.

    Make sure to handle the AStream_Terminated and Error events and then try to reconnect.

    Note that it will be much simpler and more reliable to use jServer instead.
     
  3. stefanogoria

    stefanogoria Member Licensed User

    Hi Erel, anyu other suggestions about java.net.SocketException: Connection reset
    I am try to translate in B4J a TCP server application working fine in B4A and with this error in B4J
    Which is te real problem ? there is a way to resolve ?
    Thanks a lot for your precious help
    Stefano
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Sockets are not reset automatically. Something has broke the connection. You should handle the events mentioned above.
     
  5. stefanogoria

    stefanogoria Member Licensed User

    Thanks Erel, yes I know, I would like only understand how could appen.
    I use the same hardware (RPI 2 - RPI 3) for the server powerd by linux - java or Androind
    and I use same hardware for client devices (some esp8266 wifi devices and various android devices)
    In case the server is running with android and B4A application all is working fine, in the other case (B4J jar running on linux) I have this error.
    Thanks a lot again for all
    Stefano
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    The problem is not in B4J. B4J will never close the socket.
     
Loading...