Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use PHP WebSocket in Heroku?, it seems by default there's only support for other technologies

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.

like image 615
Diego Michel Avatar asked Feb 04 '15 18:02

Diego Michel


People also ask

Can you use WebSockets with Heroku?

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.

Can you use WebSockets with PHP?

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.

Does Heroku work with PHP?

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.

What is the difference between WebSocket and socket IO?

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.


1 Answers

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

like image 198
kayleighsdaddy Avatar answered Oct 24 '22 03:10

kayleighsdaddy