gilmaimon / ArduinoWebsockets

A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)
GNU General Public License v3.0
461 stars 98 forks source link

how i can connect websocket client with token in header to server (ESP8266) #87

Closed sachinbaghel14 closed 4 years ago

sachinbaghel14 commented 4 years ago

In my ESP8266 application, i would like to connect web socket server, but while connecting i need to send token (already generated JSON token) in header. When i tried to connect without token it will diffuse connection. Please suggest me any solution so I can connect my esp8266 with websocket server (How i can add token in header of websocket client)

Please suggest any example program.

gilmaimon commented 4 years ago

If you need to add a new header you can use addHeader on your client.

If you need to pass it as a GET parameter you can just add /?key=value to your URL.

Gil.

sachinbaghel14 commented 4 years ago

can you tell me how can i use addHeader and where should i use it. I am trying to implement it on Esp8266-Client expample @gilmaimon

gilmaimon commented 4 years ago

Before you call client.connect(..), call client.addHeader(key, value)

sachinbaghel14 commented 4 years ago

okk thankyou 👍