B4J Question Strange problem with WebSocket

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!

Trying to send a specific serialised map type from B4J to mobile client (B4A) via web socket connection, an error is occurring at the server side.

The code executing is:
B4X:
Public Sub SendMessages(Messages As List)
    ws.RunFunction("NewMessage", Messages)
    ws.Flush
End Sub
where Messages List is not empty! It has the item:
B4X:
(ArrayList) [360, eJwT4WBgYGBkARIhlQWpjMxARpB7ECNItCg/McUvMTeVkQ/IOdd2bvO5vec7zzefbzm3nZELJl+am5RaxMgAMkQAKuZbmpeZnFmQmJNZUskoBNI75dzOc1vP957bcb4VaEYzUD8TUDg5ghGk0QDCiYRyWKGmRKDxofIAxh8uAw==]
with the following structure:
B4X:
Private peMap As Map
peMap.Initialize
peMap.Put("Type","POK")
peMap.Put("cid"  ,cid) 'where cid = "1007898"
then I call:
B4X:
Private peMapS As String = Utils.ConvertObjectToString(peMap)
CallSubDelayed3(PushWebShared,"SendClientMessage",peMapS,id)
and the error is:
B4X:
Error occurred on line: 863
java.lang.RuntimeException: java.lang.NullPointerException
    at anywheresoftware.b4j.object.WebSocket.set(WebSocket.java:142)
    at anywheresoftware.b4j.object.WebSocket.set(WebSocket.java:132)
    at anywheresoftware.b4j.object.WebSocket.RunFunction(WebSocket.java:298)
    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:498)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:676)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:487)
    at anywheresoftware.b4a.keywords.Common.access$0(Common.java:467)
    at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:541)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:119)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:153)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    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:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at rm.rmtunnel.main.main(main.java:29)
Caused by: java.lang.NullPointerException
    at anywheresoftware.b4j.object.WebSocket.set(WebSocket.java:139)
    ... 31 more

Note that other serialised maps are transferred without problems!
Any idea what could cause this?

Thank you in advance!
 
Last edited:

vfafou

Well-Known Member
Licensed User
Longtime User
Put a breakpoint in PushWebShared SendClientMessage and see what exactly happens there.
Good morning Erel!
I have already done this and the line causing the error is:
B4X:
ws.RunFunction("NewMessage", Messages)
but Messages List is not empty!
 
Upvote 0
Top