Open SasinduDilshara opened 1 year ago
This probably happens due to the HTTP version mismatch. WebSockets support the HTTP 1.1 version. In Ballerina, the default HTTP version is 2.0 (in the ballerina/http
module). Change the HTTP version of the listener and this should work.
However, I think ideally it should be handled from the WebSocket module itself.
listener http:Listener 'listener = check new(9090, {
httpVersion: http:HTTP_1_1
});
hi, i would like to work on this issue
👋 Welcome, @t-trafer! 🚀
We're thrilled to have you join the Ballerina Lang community! Whether you're a seasoned developer or just starting your journey with Ballerina, we value your contributions and look forward to collaborating with you. To help you get started, here are some essential resources:
Remember, no contribution is too small, and your feedback is invaluable. Feel free to ask questions, propose ideas, or report issues. Together, we can make Ballerina even better! Happy coding! 🎉
hi, i would like to work on this issue
I have assigned the issue for you.
To give you some context,
This error is occurring due to the Ballerina HTTP module using HTTP 2.0 by default, but the WebSocket needs HTTP 1.1. Therefore, when you pass an HTTP listener with default configs, the WebSocket listener initialization fails.
There are two approaches of handling this:
@Bhashinee any thoughts on this?
I prefer the first one. With the second approach, we are internally doing manipulations that are not visible to the user. So when this listener is used with another HTTP service, the user might think it is running as an HTTP/2 listener even though we have changed that internally to use HTTP/1.1. With the first approach, the user becomes aware of that change as he is the one who has to configure it in the listener.
I prefer the first one. With the second approach, we are internally doing manipulations that are not visible to the user. So when this listener is used with another HTTP service, the user might think it is running as an HTTP/2 listener even though we have changed that internally to use HTTP/1.1. With the first approach, the user becomes aware of that change as he is the one who has to configure it in the listener.
+1
Thanks for the heads up and suggestions! going ahead with the first approach
@t-trafer Are you working on this?
Kindly assign this to me, under Hacktoberfest 2024. I will try to solve this
Kindly assign this to me, under Hacktoberfest 2024. I will try to solve this
Thank you for participating in Hacktoberfest with Ballerina. I have assigned the issue to you now.
I tried to initiate a websocket connection with following program.
This not worked properly. I got the following response