socket.io-client-cpp icon indicating copy to clipboard operation
socket.io-client-cpp copied to clipboard

Is Socket.IO-client c++ can connect to "https" server?

Open linuxrd007 opened this issue 3 years ago • 4 comments

As title, my company use socket.io v3 or higher, I try to connect to server but there are no any connected message in server side!? The server was tested by Socket.IO client Tools([https://amritb.github.io/socketio-client-tool/])

I reference example as follow: image

It's can not connect, as follows. sio::client h; h.connect("https://207.148.98.240:4000");

How to connect to "https"? Thank you.

linuxrd007 avatar Mar 10 '22 12:03 linuxrd007

Hi, if you want to use HTTPS you need to make sure that you built the TLS version of the socket.io C++ library. To do so you need to link against the OpenSSL libraries and pass the SIO_TLS preprocessor definition when compiling.

jmigual avatar Mar 10 '22 13:03 jmigual

Hi,

After link "openssl" and define "SIO_TLS" but still error occur, please reference Code::Blocks setting as follows.

NB_Image_20220322_131555

NB_Image_20220322_131611

compiler error log: NB_Image_20220322_141251

search openssl file path: NB_Image_20220322_131640

I found many the same "openssl" file, which one is correct?

Thank you.

linuxrd007 avatar Mar 22 '22 05:03 linuxrd007

Hi to be able to compile OpenSSL on a raspberry pi you should install the libssl-dev package: sudo apt install libssl-dev

jmigual avatar Apr 13 '22 07:04 jmigual

I had some issue when trying to open a socket with https (unsupported URI scheme). For future reference for people having the same issue as me; to fix it I had to change this:

  • target_link_libraries(project sioclient) -> target_link_libraries(project sioclient sioclient_tls)
  • clone on branch 2.x-tls instead of 2.x
  • install deps with apt-get update && apt-get install -y libssl-dev

Vicidel avatar Jun 29 '23 10:06 Vicidel