engapplabs / flutter_websocket_plugin

Plugin with native integration for WebSocket.
MIT License
33 stars 31 forks source link

Handling HTTP errors #11

Open valentinvan opened 4 years ago

valentinvan commented 4 years ago

Hi @luanhssa,

First of all, thanks for the plugin really easy to use and setup. Great work!

I'm wondering, do you think you could add something like a listener for when HTTP errors are triggered? For example, sometimes my websocket would return:

W/System.err(11581): java.net.ProtocolException: Expected HTTP 101 response but was '403 Forbidden'

W/System.err(11581):    at okhttp3.internal.ws.RealWebSocket.checkUpgradeSuccess$okhttp(RealWebSocket.kt:185)
W/System.err(11581):    at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:156)
W/System.err(11581):    at okhttp3.RealCall$AsyncCall.run(RealCall.kt:140)
W/System.err(11581):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(11581):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(11581):    at java.lang.Thread.run(Thread.java:764)

But there is not any way (or I didnt find any way) of capturing that exception and for example, trying to reconnect to my websocket again.

Thanks!

luanhssa commented 4 years ago

Thank you for your feedback!

I’ve spent some time away from this plugin cause was done in a past workplace, but they don’t want it anymore (and they didn’t continue it). I’ll return to work on this plugin and update it as well to fit the latest flutter version.

Also, I’ll add the feature you mentioned.

Thanks again for your email!

On Fri, 28 Aug 2020 at 04:03 valentinvan notifications@github.com wrote:

Hi @luanhssa https://github.com/luanhssa,

First of all, thanks for the plugin really easy to use and setup. Great work!

I'm wondering, do you think you could add something like a listener for when HTTP errors are triggered? For example, sometimes my websocket would return:

W/System.err(11581): java.net.ProtocolException: Expected HTTP 101 response but was '403 Forbidden' W/System.err(11581): at okhttp3.internal.ws.RealWebSocket.checkUpgradeSuccess$okhttp(RealWebSocket.kt:185) W/System.err(11581): at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:156) W/System.err(11581): at okhttp3.RealCall$AsyncCall.run(RealCall.kt:140) W/System.err(11581): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err(11581): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err(11581): at java.lang.Thread.run(Thread.java:764)

But there is not any way (or I didnt find any way) of capturing that exception and for example, trying to reconnect to my websocket again.

Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/engapplabs/flutter_websocket_plugin/issues/11, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMDCKXUSDCTYKD5RCW6OHTSC5JEPANCNFSM4QNZXSCA .

-- Sincerely,

Luan Almeida

ghost commented 3 years ago

the same problem. please fix this issue.

Thiago97SLA commented 3 years ago

Hi @luanhssa https://github.com/luanhssa, Hello, could you help me with a problem I have with the library

W/System.err(13883): java.net.ProtocolException: Expected HTTP 101 response but was '403 Forbidden' W/System.err(13883): at okhttp3.internal.ws.RealWebSocket.checkUpgradeSuccess$okhttp(RealWebSocket.kt:196) W/System.err(13883): at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:167) W/System.err(13883): at okhttp3.RealCall$AsyncCall.run(RealCall.kt:138) W/System.err(13883): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err(13883): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err(13883): at java.lang.Thread.run(Thread.java:919)