B4J Question [ABMaterial] Old Android Phone

PCastagnetti

Member
Licensed User
Longtime User
On an old Android smartphone using the stock browser I always get this error (Ver 2.03).

java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:378)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:190)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
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:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at italretail.prenota.main.main(main.java:29)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:375)
... 15 more
Disconnected
java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:378)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:190)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
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:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at italretail.prenota.main.main(main.java:29)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:375)
... 15 more
Disconnected
java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:378)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:190)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
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:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at italretail.prenota.main.main(main.java:29)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:375)
... 15 more
.......
.....
......
.....
This happens before the WebSocket_Connected event.
The real problem is that you enter into a loop of disconnections.
Is there a way to identify such browsers and eventually send an error message to the user?

Thank you
 

alwaysbusy

Expert
Licensed User
Longtime User
Can you try these new b4j_ws/b4j_ws.min files?

It seems to be impossible to find out if a stock browser is being used (I searched the whole night, and nobody can find a 100% sure way), so I now do a check if Androids version is below 6.0. In that case I use ReconnectWebSocket, else the new RobustWebSocket.

Take a backup of your existing b4j_ws.js and b4j_ws.min.js files!

Notes:

1. for this test, you MUST add Page.NeedsPlatform = true in the BuildPage for ABMApplication and each of your own pages. This will not be needed for the new version.
2. @mindful Does not apply for you. I'm now finishing up a test for 2.12 for you and I mail it for testing.
 

Attachments

  • Newb4j_wsFor203.zip
    11.2 KB · Views: 204
Upvote 0
Top