Node red - websocket - php connection

1,356 views
Skip to first unread message

Manu Vollmann

unread,
Jun 12, 2017, 2:08:35 PM6/12/17
to Node-RED
Hi,

I'm very new to all of the topics (node red, websockets and php).

I want to use node red for pushing mqtt messages via websocket to my php page and vice versa. I tried some websocket/node red demos and they are all working fine. I now stayed with this demo https://flows.nodered.org/flow/8666510f94ad422e4765 because I only need a button embedded in my php which sends a message through the websocket.

When I use localhost:1880/simple it's working (obviously). 

But I don't know how to embedd this button in my php page. When I just include the /simple url in a php file it doesn't get a connection. When I paste the html code to my php file it's the same. (Opcode -1)

First I thought it can't be that difficult but as I don't know websockets it feels like a kind of a life-task. 

The easiest possibility would be a php palette but as far as I could google it there is no available package. Does anyone know how to get such a cross connection between websockets and php pages.

background: I need the php page because I had to do a login, session, mysql queries, ....

Cheers
Message has been deleted

Ali Muntaha

unread,
Sep 27, 2017, 5:49:39 AM9/27/17
to Node-RED
This is my solution and work fine.

Download this script and save eg:websocket.php on your htdocs of your http server. Change with your node red ip address.
Open your browser http://localhost/websocket.php. Now you will control your node red from your php script.

websocket.php
websocket.json
Reply all
Reply to author
Forward
0 new messages