WebSocket Issue

Hello, I have a PHP socket server that manages a messaging system. The security of my site is handled by Cloudflare, and a tunnel has been created to connect the base server to the final site. However, I’m encountering an issue trying to pass my socket through this tunnel. I’m not sure if this is the correct approach, but I added a public hostname, allowing me to add a subdomain to my site to internally connect my socket to the right port via a client-usable URL. When I connect with JavaScript, the connection is established, but my socket doesn’t echo anything, even though it should notify me when someone connects. When I stop the PHP program, the socket closes on the client side, indicating that the connection seems to be established nonetheless. I had tested my socket locally on a MAMP, and it worked perfectly. This doesn’t seem very logical to me. Do you have a solution to my problem? Thanks in advance.
1 Reply
niconiahi
niconiahi3mo ago
I think that you can't maintain the WS connection. You can do it if you maintain the WS state and connection using a Durable Object the reason being that the Cloudflare runtime expects to receive the response (wake up right there), return the response and destroy itself if I'm wrong, please someone correct me