Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown protocol: ws #30

Open
XDao7 opened this issue Jan 10, 2024 · 2 comments
Open

unknown protocol: ws #30

XDao7 opened this issue Jan 10, 2024 · 2 comments

Comments

@XDao7
Copy link

XDao7 commented Jan 10, 2024

我在Android Studio中使用implementation("dev.icerock.moko:socket-io:0.4.0")的方式引入了这个库,然后按照readme的示例代码,使用了ws://...类型的地址,发生了如下报错:

Caused by: java.lang.RuntimeException: java.net.MalformedURLException: unknown protocol: ws
	at io.socket.client.Url.parse(Url.java:52)
	at io.socket.client.IO.socket(IO.java:61)
	at io.socket.client.IO.socket(IO.java:42)
	at dev.icerock.moko.socket.Socket.<init>(Socket.kt:25)

在socket.io-client-java中查找到了类似的issues,看起来socket.io-client-java已经修复了这个问题。在io.socket.client.IO类中使用了URI而不是URL。

The following is the translation:
I introduced this library in Android Studio using implementation("dev.icerock.moko:socket-io:0.4.0"), and then used the ws://... type address according to the sample code in the readme. , the following error occurred:

Caused by: java.lang.RuntimeException: java.net.MalformedURLException: unknown protocol: ws
	at io.socket.client.Url.parse(Url.java:52)
	at io.socket.client.IO.socket(IO.java:61)
	at io.socket.client.IO.socket(IO.java:42)
	at dev.icerock.moko.socket.Socket.<init>(Socket.kt:25)

Similar issues were found in socket.io-client-java. It seems that socket.io-client-java has Fixed this issue.URI is used instead of URL in io.socket.client.IO class.

@XDao7
Copy link
Author

XDao7 commented Jan 10, 2024

Is there something wrong with my usage? I didn’t find any documentation on how to introduce it in Android Studio.

@XDao7
Copy link
Author

XDao7 commented Jan 10, 2024

After testing, this problem can be solved by specifying the socket.io-client-java version

implementation("io.socket:socket.io-client:2.1.0") {
    exclude(group = "org.json", module = "json")
}

If do this, you can only receive four default messages: EVENT_CONNECT, EVENT_DISCONNECT, EVENT_CONNECT_ERROR, and EVENT_MESSAGE.
It is uncertain whether there are other effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant