Search code examples
javaandroidplayn

"java.lang.UnsupportedOperationException" using Net.WebSocket on android


I'm just trying to connect to my websocket server :

ws = net().createWebSocket("ws://192.168.0.3:8000/sample", this);

It works fine when I test it with mvn test -Pjava

But when I load it with my Google Nexus S (under Icecream sandwich), I get :

E/AndroidRuntime( 4321): FATAL EXCEPTION: GLThread 352
E/AndroidRuntime( 4321): java.lang.UnsupportedOperationException
E/AndroidRuntime( 4321):        at playn.core.NetImpl.createWebSocket(NetImpl.java:27) 
E/AndroidRuntime( 4321):        at com.github.dawicorti.qrcomsample.core.CommunicationScreen.<init>(CommunicationScreen.java:34)
E/AndroidRuntime( 4321):        at com.github.dawicorti.qrcomsample.core.QRComSample.init(QRComSample.java:12)
E/AndroidRuntime( 4321):        at playn.android.AndroidPlatform.run(AndroidPlatform.java:170)
E/AndroidRuntime( 4321):        at playn.core.PlayN.run(PlayN.java:47)
E/AndroidRuntime( 4321):        at com.github.dawicorti.qrcomsample.android.QRComSampleActivity.main(QRComSampleActivity.java:13)
E/AndroidRuntime( 4321):        at playn.android.GameViewGL$3.run(GameViewGL.java:94)
E/AndroidRuntime( 4321):        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
E/AndroidRuntime( 4321):        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
W/ActivityManager(  249):   Force finishing activity com.github.dawicorti.qrcomsample.android/.QRComSampleActivity

Solution

  • WebSockets are (as of March 2013), not supported in the Android backend. They're only supported in the Java and HTML backends.

    I'll update the platform status page.