Custom headers in Websocket Protocol messages - websocket

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

Related

Web Request to MQTT Wrapper/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.

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?

MQTT over websocket in c

I have implemented mqtt using server connection tcp socket on my machine with mosquitto broker. I have totally understood the mqtt protocol and its frame format. I want to publish my data over webserver which supports mqtt over websocket.
How can I start with this thing?
I am not clear with websocket concept
Can I implement websocket using tcp or is there any other method.
do i have to use http to implement mqtt over web socket as to send data over webserver?
As http and mqtt use different methods to send or receive data.
I don't want to use ready libraries such as paho.
I am totally new to this socket programming.any help or guideline will greatly appreciated!!!
Websockets are an extension to the HTTP protocol, you need to use a correctly formatted HTTP request to setup a new Websocket connection.
Once the connection is setup it can be used to send the exact same binary MQTT packets that you would send over an existing TCP connection.
I suggest you look at using an existing library like libwebsockets to handle the Websocket connection setup, then you should be able to interface your existing code to just use the websocket handle instead of the socket handle.
If you REALLY don't want to use a library then you will need to start by reading the Websocket RFC https://www.rfc-editor.org/rfc/rfc6455

Advanced Restclient socket implementation can not connect to Spring Websocket

I have developed a chat application by using Spring Stomp and socketjs .
I have successfully connected to the websocket over my clients but I can not connect to websocket by using Advanced Restclient -> socket implementation.
Why?
Thanks
if i didnt use socketjs , i can succeed to connect over Advanced Rest Client. To connect websocket without using socketjs, you should set the allowed origins : setAllowedOrigins('*')
Also if you are using stomp without socketjs , you can succeed to open a websocket connection via Advanced Rest Client, because stomp just a sub-protocol over websocket connection. But to receive messages over websocket, you should subscribe to STOMP queue, it is impossible with Advanced Rest Client.
-
Restclients runs on http protocol. Restclients not yet understand the web socket and sock JS protocol. That is the reason your rest client didn't connected to server.

RabbitMQ Web STOMP without SockJS

Is it possible to setup RabbitMQ Web STOMP connection without SockJS library?
I have played around with rabbitmq-web-stomp plugin without a success as the initial response generated by the server is Welcome to SockJS! (which is obviously not a STOMP based message).
Is SockJS really required? What does it bring into the game (besides legacy browser support)?
SockJS protocol does support raw WebSocket clients under /websocket path.
Any SockJS server complying with 0.3 protocol does support a raw WebSocket url. The raw WebSocket url for the test server looks like:
ws://localhost:8081/echo/websocket
You can connect any WebSocket RFC 6455 compliant WebSocket client to this url.
This is supported by Rabbit's implementation as well. So the default endpoint is: http://example.com:15674/stomp/websocket.

Resources