Web Request to MQTT Wrapper/Proxy - proxy

Is there a wrapper or proxy between HTTP Request and MQTT?
I want to send all Web request to PHP Server, which will submit that request to MQTT Server, while my iOT device which subscribe to the same topic will send back MQTT message and PHP Server will response that message back the requester
Request: Web Browser—->PHP Server or whatever→MQTT Broker->IOT DEVICE
Response: IOT DEVICE->MQTT Broker->PHP Server->Web Browser
I have used some HTTP/MQTT VPN broker but it requires 5 to 6 MQTT messages just to establish the connection which cause a lot of trouble when connection is unstable.

Related

How to establish a websocket connection from a Twilio webhook?

I am trying to create a chat messaging application, which has text functionality. Right now, when a user sends an SMS message from their phone to a Twilio service number, there is a Twilio webhook which redirects to an endpoint in my backend server: sending HTTP POST request.
However, since it is a chat messaging application, I need the Twilio webhook to establish a Websocket connection (upgrading over HTTP) to my backend server, so that it can send websocket events back to my client.
Is there a way to establish a websocket connection using Twilio webhooks, or even Twilio functions? I can't find any resources online to solve this issue.
I tried Twilio Webhooks, and Twilio Functions, it hasn't worked so far.
WebSockets won't help you in this situation, as the webhook timeout limit is 15 seconds. This means you either need to return a TwiML response within 15 seconds or the request will fail.
It sounds like you want to build a stateful WebSocket connection instead of the stateless API callback. To achieve a stateful session, you either need to handle the state management over multiple incoming messages on your own, or you can use a Studio Flow which comes with state management baked in.

problem in sending polling requests in socket.io

I am using easyrtc and socket.io for my metaverse application. The socket.io uses pollings and websocket connection for providing the multiuser experience in my metaverse.
The client sends polling requests to my server for connection.
At times the path at which the client sends request is taken as localhost:3000 which is my client itself. I want it to serve requests to my server that is present at localhost:3333.
Sometimes it sends requests to localhost:3000 and sometimes it sends the requests correctly to localhost:3333.
Can someone help?

Remote Websocket server performance

I have created a php websocket server, and a php websocket client, the websocket client communicate with the server using JSON format, each message means an operation to handle by the websocket server.
when running both the client and the server in localhost I can reach about 35 operations/sconds, and the same results when running both client and websocket server on the production server, but running client in locahost (my machine) with production websocket server (remote) that only results in 5 operations/seconds.
What could be the reason behind that bad performance when using remote websocket server?
Solved by changing websocket client app logic (sending messages asynchronously instead of synchronously), by using that approach we have increased the score to more than 100 operations/s.
Credits to Jérôme Richard (See the question comments)

WebSocket security of incoming connection to clients

I have written WebSocket server with token authentication where the client connects as:
socket = new WebSocket("wss://websockets", ["hub", token] )
It uses subprotocol to squeeze auth token within headers.
On the server side I intercept this header key and authorize the request which works great - the client connects ok and keeps the connection open.
When token is not supplied, connection is rejected - great!
So in the typical use case: chat application, the user logins and gets authorization token to open the connection. Once connection is opened the client sends message to the server and the server sends that message to all connected clients.
So, so far I understand that the opening connection to the server and sending message to it is secured. What happens when that message is pushed to all connected clients? I don´t need to be concerned about authorization of incoming messages (to the client) since the client needs to be connected and therefore authorized to receive those messages right?

Custom headers in Websocket Protocol messages

I'm using Netty to create a WebSocket application. I'm able to send HTTP Headers during start of connection but I'm unable to send custom headers with messages after establishing connection.
Is it possible to send custom headers with messages after establishing connection in WebSockets? Any example would be appreciated

Resources