B4J Question Error when I use FCM & Websocket togather

alimanam3386

Active Member
Licensed User
Longtime User
Hi

When I use web socket server (B4J) to send a message with FCM I get bellow error :

B4X:
{"data": {"receivertoken": "receivertoken-here","pmsenderid": "SenderId HERE","body": "hi my friend !"},
"to": "AcQQ4p4WI1g:APA91bGhKhiydgATbIkNgzu5F6WGF5pm_HxLM9lNSA7bHM0dg89sCbpgpEQc3srf4J92oZkyKd3DId5HqroBmWMWkGCVMHYvxOY1nYrcV6GnTJ--x2T61igugVdDwgCM-D-OJPzZThze"
}

java.lang.RuntimeException: java.lang.IllegalStateException: Toolkit not initialized
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$1.run(WebSocketModule.java:126)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:195)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:273)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:268)
at javafx.application.Platform.runLater(Platform.java:83)
at anywheresoftware.b4j.objects.FxBA.postRunnable(FxBA.java:17)
at anywheresoftware.b4a.keywords.Common.CallSubDelayed4(Common.java:500)
at anywheresoftware.b4a.keywords.Common.CallSubDelayed2(Common.java:484)
at b4j.example.httpjob._postbytes(httpjob.java:215)
at b4j.example.httpjob._poststring(httpjob.java:261)
at b4j.example.b4a._v6(b4a.java:123)
at b4j.example.b4a._pm_message(b4a.java:79)
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:93)
... 10 more

I attached my source code , how can I solve this error ?
 

Attachments

  • Client-b4a.zip
    11.4 KB · Views: 176
  • Server-B4J.zip
    1.6 KB · Views: 168

alimanam3386

Active Member
Licensed User
Longtime User
You should use jOkHttpUtils2_NONUI instead of jHttpUtils2.

Hi Erel

I get another error ! after I used jOkHttpUtils2_NONUI instead of jHttpUtils2 it was worked fine but after 2 hours I dont know what's happen :(

B4X:
java.net.UnknownHostException: fcm.googleapis.com
   at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
   at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
   at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
   at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
   at java.net.InetAddress.getAllByName(InetAddress.java:1192)
   at java.net.InetAddress.getAllByName(InetAddress.java:1126)
   at com.squareup.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
   at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)
   at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)
   at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)
   at com.squareup.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)
   at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)
   at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
   at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
   at com.squareup.okhttp.Call.getResponse(Call.java:273)
   at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230)
   at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201)
   at com.squareup.okhttp.Call.execute(Call.java:81)
   at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.executeWithTimeout(OkHttpClientWrapper.java:143)
   at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.access$0(OkHttpClientWrapper.java:140)
   at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$ExecuteHelper.run(OkHttpClientWrapper.java:188)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)
[jobname=fcm, success=false, username=
, password=, errormessage=java.net.UnknownHostException: fcm.googleapis.com, target=[vv1=anywheresoftware.b4j.object.WebSocket@747bd675, vv2=anywheresoftware.b4a.objects.Timer@70445c22, api_key= my api_key was here :)
, vv3=null, vv4=null]
, taskid=4, req=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest@55692301, tag=java.lang.Object@201f595c
, httputils2service=null]
 

Attachments

  • 143JU9OL.jpg
    143JU9OL.jpg
    62.6 KB · Views: 199
Upvote 0
Top