I've made a chat room app, I tested locally and it works, but when I deploy it to heroku, there's a CONNECTION REFUSE ERROR, I saw that heroku now support WebSocket, but it seems it's only for all supported technologies but PHP.
The normal Heroku HTTP routing timeout rules apply to WebSocket connections. Either client or server can prevent the connection from idling by sending an occasional ping packet over the connection.
The WebSocket is used to create a bridge to send or receive messages from the PHP chat server. In the web world, we generally use HTTP request methods to communicate between the client and server side. In this chat example, we use sockets to communicate with the server.
Heroku recognizes an app as PHP by the existence of a composer. json file in the root directory. The composer. json file specifies the dependencies that should be installed with your application.
Key Differences between WebSocket and socket.io It provides the Connection over TCP, while Socket.io is a library to abstract the WebSocket connections. WebSocket doesn't have fallback options, while Socket.io supports fallback. WebSocket is the technology, while Socket.io is a library for WebSockets.
Yes you can use WebSocket in Heroku. PHP is a very difficult language in general when it comes to WebSockets and I would recommend a different one. But regardless of what I think, you may do as you please. If you are using Heroku, you have to follow the standard rules of idle. If a program reminds idle for 55 seconds the program will be terminated. The way to handle this would be to send a ping message from the server every 30ish seconds.
https://devcenter.heroku.com/articles/websockets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With