B4J Question First push to IOS causes always a java.net.SocketException:

schimanski

Well-Known Member
Licensed User
Longtime User
I'm using a variation of Erel's B4X-Push-Server. The first push to an ios-device causes the following exception and the push-message doesn't arrive on the iphone. After the reconnect, it is no problem to push the device, but even, if i wait an hour or something, the exception raised against with the first push. What is the reason for that? I'm using the sandbox.

B4X:
2015-10-12 18:52:08,642 [qtp1712669532-3054] TRACE  - Datei auf dem EIS-Server e
ingegangen:EIS/Kontakte/iPhone6/1444668732258.Stammi.txt
2015-10-12 18:52:08,642 [main] DEBUG  - 1 IOS-Device pushed!
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at sun.security.ssl.InputRecord.readFully(Unknown Source)
        at sun.security.ssl.InputRecord.read(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
        at sun.security.ssl.AppInputStream.read(Unknown Source)
        at java.io.InputStream.read(Unknown Source)
        at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStrea
ms.java:184)
        at java.lang.Thread.run(Unknown Source)
2015-10-12 18:52:08,896 [main] ERROR  - Fehler: java.net.SocketException: Connec
tion reset
2015-10-12 18:52:08,896 [main] INFO   - Try to reconnect!.
..
java.lang.UnsupportedOperationException: The method shutdownInput() is not suppo
rted in SSLSocket
        at sun.security.ssl.BaseSSLSocketImpl.shutdownInput(Unknown Source)
        at anywheresoftware.b4a.objects.SocketWrapper.Close(SocketWrapper.java:1
88)
        at de.sekutor.eisserver.iospush._vvvvvvvvvvv2(iospush.java:92)
        at de.sekutor.eisserver.iospush._timer1_tick(iospush.java:238)
        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 anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
        at anywheresoftware.b4a.BA$3.run(BA.java:178)
        at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(Simple
MessageLoop.java:30)
        at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
        at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131
)
        at de.sekutor.eisserver.main._appstart(main.java:175)
        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 anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
        at de.sekutor.eisserver.main.main(main.java:29)
2015-10-12 18:52:12,930 [main] INFO   - Mit IOS-Push-Socket verbunden!
 

schimanski

Well-Known Member
Licensed User
Longtime User
You are right, Erel! the most of the exception were from an invalid token, thanks for that. But the problem is the same. After sending the first message, i always get an
B4X:
10/13/2015 08:56:43: 2015-10-13 08:54:56,741 [main] ERROR  - Fehler: java.net.SocketException: Connection reset

and the push doesn't arrives. After the reconnect, everything runs fine until I wait again some time.:(

I can't understand, why the timer doesn't reconnects the connection form time to time. It seems, that the _terminated event will not be raised and after the first push, the _error event is raised and starts a reconnect...

B4X:
Private Sub Connect
    Try
        If sock.IsInitialized Then sock.Close
        Dim sock As Socket
        sock.InitializeSSL("sock", File.OpenInput(Main.iPushKeystore, ""), Main.iPushKeystorePassword)
        sock.Connect(Main.iGateway, Main.iGateWayPort, 30000)
    Catch
        Main.Logger.logsERROR("Fehler beim Push-Connect:" & LastException.Message)
    End Try
End Sub

Private Sub sock_Connected (Successful As Boolean)
    If Successful Then
        timer1.Enabled = False
        Main.Logger.logsINFO("Mit IOS-Push-Socket verbunden!")
        If astream.IsInitialized Then astream.Close
        astream.Initialize(sock.InputStream, sock.OutputStream, "astream")
    Else
        Main.Logger.logsWARN("Fehler Verbindungsaufbau IOS-Push-Socket: " & LastException.Message)
        Reconnect
    End If
End Sub

Private Sub Reconnect
    Main.Logger.logsINFO("Versuche Verbindung wieder herzustellen...")
    timer1.Enabled = True
End Sub

Private Sub Timer1_Tick
    timer1.Enabled = False
    Connect
End Sub

Private Sub astream_NewData (Buffer() As Byte)
    If Buffer.Length >=6 Then
        Main.Logger.logsDEBUG("Status=" & Buffer(1))
    Else
        Main.Logger.logsDEBUG("Invalid response")
    End If
End Sub
Private Sub astream_Error
    Main.Logger.logsERROR("Fehler: " & LastException.Message)
    Reconnect
End Sub
Private Sub astream_Terminated
    Main.Logger.logsWARN("unterbrochen")
    Reconnect
End Sub
 
Last edited:
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I have checked the tokens database, everything ok. Is it possible, that in sandbox the terminated-event doesn't raises?
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I made an adhoc-certificate to test it with the production-servers. After exactly 5 minutes and 30 seconds don't sending a message, i got again the following exception, only with the first push:confused:...I don't have an idea...

B4X:
java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:209)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
    at sun.security.ssl.InputRecord.read(InputRecord.java:503)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:930)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
    at java.io.InputStream.read(InputStream.java:101)
    at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:184)
    at java.lang.Thread.run(Thread.java:745)
2015-10-14 11:25:51,302 [main] ERROR  - Fehler: java.net.SocketException: Connection reset
2015-10-14 11:25:51,302 [main] INFO   - Versuche Verbindung wieder herzustellen...
java.lang.UnsupportedOperationException: The method shutdownInput() is not supported in SSLSocket
    at sun.security.ssl.BaseSSLSocketImpl.shutdownInput(BaseSSLSocketImpl.java:215)
    at anywheresoftware.b4a.objects.SocketWrapper.Close(SocketWrapper.java:188)
    at de.sekutor.eisserver.iospush._connect(iospush.java:144)
    at de.sekutor.eisserver.iospush._timer1_tick(iospush.java:325)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:563)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:221)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
    at anywheresoftware.b4a.BA$3.run(BA.java:178)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:103)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:292)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at de.sekutor.eisserver.main.main(main.java:29)
2015-10-14 11:25:55,200 [main] INFO   - Mit IOS-Push-Socket verbunden!
 
Upvote 0
Top