socketio / socket.io-client-java

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.
https://socketio.github.io/socket.io-client-java/installation.html
Other
5.33k stars 975 forks source link

RoboVM java.lang.IllegalArgumentException: unexpected url. #215

Closed ollyde closed 9 years ago

ollyde commented 9 years ago

I'm using this excellent implementation of sockets for my cross-platform projects, keep up the good work!

BUT! I know there's no real support for it and it's probably not in you're scope but my problem is I'm using RoboVM to compile my Java code into machine code for iOS, everything works perfect except something is broken on the connection with this library.

I'm using this implementation

//192.168.1.11:9999 OR https://192.168.1.11:9999
URI uri = new URI(ServerController.WEB_SERVER_API);  
socketIOClient = IO.socket(uri);
socketIOClient.on(Socket.EVENT_CONNECT, new Emitter.Listener()

I get the following error:

OLLY:LOG: Connecting with server: http://192.168.1.11:9999
java.lang.IllegalArgumentException: unexpected url: http://192.168.1.11:9999/socket.io/?EIO=3&sid=3x4xcfIDbrYeX7RlAAAH&transport=websocket
        at com.squareup.okhttp.Request$Builder.url(Request.java:153)
        at io.socket.engineio.client.transports.WebSocket.doOpen(WebSocket.java:53)
        at io.socket.engineio.client.Transport$1.run(Transport.java:76)
        at io.socket.thread.EventThread.exec(EventThread.java:50)
        at io.socket.engineio.client.Transport.open(Transport.java:71)
        at io.socket.engineio.client.Socket.probe(Socket.java:459)
        at io.socket.engineio.client.Socket.onOpen(Socket.java:472)
        at io.socket.engineio.client.Socket.onHandshake(Socket.java:512)
        at io.socket.engineio.client.Socket.onPacket(Socket.java:486)
        at io.socket.engineio.client.Socket.access$900(Socket.java:30)
        at io.socket.engineio.client.Socket$5.call(Socket.java:300)
        at io.socket.emitter.Emitter.emit(Emitter.java:117)
        at io.socket.engineio.client.Transport.onPacket(Transport.java:124)
        at io.socket.engineio.client.transports.Polling.access$700(Polling.java:16)
        at io.socket.engineio.client.transports.Polling$2.call(Polling.java:123)
        at io.socket.engineio.parser.Parser.decodePayload(Parser.java:255)
        at io.socket.engineio.client.transports.Polling._onData(Polling.java:133)
        at io.socket.engineio.client.transports.Polling.onData(Polling.java:105)
        at io.socket.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:113)
        at io.socket.thread.EventThread$2.run(EventThread.java:75)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:837)

If anyone would have any ideas? tried compiling with:

compile 'io.socket:socket.io-client:0.6.1'
ollyde commented 9 years ago

It would seem the error is here:

//at io.socket.engineio.client.transports.WebSocket.doOpen(WebSocket.java:53)
Request.Builder builder = new Request.Builder().url(uri());

This creates a null URI only on RoboVM.

//at com.squareup.okhttp.Request$Builder.url(Request.java:147)
if (url == null) throw new IllegalArgumentException("url == null");

I'd like to download the library and modify it but that's broken too.

NoahAndrews commented 9 years ago

Fellow RovoVM user here! Why not just use a String, at least for now?

ollyde commented 9 years ago

I did try lots of variations of strings with no success, exactly the same error.

I even tried manually building a URI

URI uri = new URI("http", "", "192.168.1.11", 9999, "/", "", null);

Still gives the same error :-(

NoahAndrews commented 9 years ago

Have you tried stepping through the part where it crashes using the debugger? (if you have the paid version)

ollyde commented 9 years ago

I got a feeling it will lead me too the same stack trace though, it seems no matter what I put when creating a new socket in this library it crashes for iOS.

I'd like to download the library and modify it but I spent all morning just trying to get it working with no success.

Any ideas?

NoahAndrews commented 9 years ago

Just put a breakpoint just before the problem, and click the debug button. It integrates with the IDE's debugger, at least on IntelliJ.

ollyde commented 9 years ago

I've submitted a cross platform app example that works on Desktop, Android but not IOS here: https://github.com/voidstarfire/LibGDX-SocketIO-with-Node/tree/master

nuclearace commented 9 years ago

Wouldn't this be more of an issue of RoboVM not properly generating the iOS?

nuclearace commented 9 years ago

Also, on what arch are you running the iOS one on? It could be a problem with that specific architecture.

ollyde commented 9 years ago

archs = 'arm64:thumbv7'

ollyde commented 9 years ago

Flagged an issue here. https://github.com/robovm/robovm/issues/1153

ollyde commented 9 years ago

It seems to be an issue with the web sockets class in this library but I can't figure it out. I've made a test application here: https://github.com/voidstarfire/LibGDX-SocketIO-with-Node/tree/master

NoahAndrews commented 9 years ago

See Stefan's response to this thread and see if that fixes your problem https://groups.google.com/forum/#!topic/robovm/m3XC_LdBVpU

ollyde commented 9 years ago

Fixed in RoboVM 1.9

nkzawa commented 9 years ago

@voidstarfire :+1: great