did anyone use WebSocket connections between a Flutter/Dart client and a server running on Google Cloud Run successfully?
Exactly this combination fails for me.
The client works with the same server on localhost.
Another client works with the same server on Cloud Run.
I tried to find the cause of the problem, so I have created a complete bug reproducer with clients in Dart and Python and servers in Java and Python:
Dart client (the README contains the outputs of the messages sent and received and the aborted connection):
https://github.com/buehren/websocket-client-dartJava/Quarkus WebSocket Echo Server (including a "Run in Google Cloud" button):
https://github.com/buehren/websocket-echo-server-quarkusPython WebSocket Echo Server (including a "Run in Google Cloud" button):
https://github.com/buehren/websocket-echo-server-python
The Dart client works with WebSocket echo server running on localhost:
> dart run wsclient.dart --url ws://localhost:8080/websocket
2021-02-26 21:25:22.293451 Starting connection attempt to ws://localhost:8080/websocket ...
2021-02-26 21:25:22.418794 WebSocket readyState: 1
2021-02-26 21:25:23.446877 Sending 'hello'
2021-02-26 21:25:23.458083 Received data: echo of hello
2021-02-26 21:25:24.422013 Sending 'how are you?'
2021-02-26 21:25:24.422752 Received data: echo of how are you
2021-02-26 21:25:26.433450 Sending 'still there?'
2021-02-26 21:25:26.436280 Received data: echo of still there?
^C
^C
The Dart client does NOT work with WebSocket echo server running on Google Cloud Run — the WebSocket is closed right after the Dart client sends data:
> dart run wsclient.dart --url wss://websocket-echo-server-quarkus-xxxxxxxxxx-xx.x.run.app/websocket
2021-02-26 21:25:40.539316 Starting connection attempt to wss://websocket-echo-server-quarkus-xxxxxxxxxx-xx.x.run.app/websocket ...
2021-02-26 21:25:40.844298 WebSocket readyState: 1
2021-02-26 21:25:41.851590 Sending 'hello'
2021-02-26 21:25:41.898587 CONNECTION DONE!
readyState=3
closeCode=1005
closeReason=
2021-02-26 21:25:42.847345 Sending 'how are you?'
2021-02-26 21:25:44.848959 Sending 'still there?'
Do you have any idea how this can happen? Did I do anything wrong in my code?
Thank you very much
Thomas