socketio / socket.io-client-cpp

C++11 implementation of Socket.IO client
MIT License
2.26k stars 729 forks source link

build a sioclient lib with TLS #60

Closed einsitang closed 9 years ago

einsitang commented 9 years ago

my socket.io server use SSL , and I need build a socket.io cpp client to connect server with SSL.

I try build sioclient_tls like this:

cmake -DBOOST_INCLUDEDIR=/usr/local/Cellar/boost/1.58.0/include -DBOOST_LIBRARYDIR=/usr/local/Cellar/boost/1.58.0/lib -DBOOST_VER:STRING=1.58.0 -DTARGET=sioclient_tls
// is work!!

make -dSIO_TLS

make install

then , create two static lib ("libsioclient.a and libsioclient_tls.a") and “build” directory

so ,I use build/lib/Release lib andbuild/include header file and libsioclient_tls.a lib to make my cpp-client project!

but , can’t work , so many error in the logs , can’t build .

so , I use libsoclient.a to replacelibsioclient_tls.a

and compile is pass . but can’t connect the socket.io server with ssl

[2015-09-09 11:20:53][connect] Successful connection

[2015-09-09 11:20:53][error] handle_read_http_response error: websocketpp.transport:7 (End of File)

P.S.

when I use socket.io javascript client ,use https://xxxx to connect server is success.

einsitang commented 9 years ago

The question has bothered me for a long time, but I don't know how to solve

einsitang commented 9 years ago

someone help me?

einsitang commented 9 years ago

I just make my project pass in Ubuntu System , but on my Mac , is not work , still error

Undefined symbols for architecture x86_64:

"_SSLv2_client_method", referenced from:

  boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in libsioclient_tls.a(sio_client_impl.cpp.o)

"_SSLv2_method", referenced from:

  boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in libsioclient_tls.a(sio_client_impl.cpp.o)

"_SSLv2_server_method", referenced from:

  boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in libsioclient_tls.a(sio_client_impl.cpp.o)

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

einsitang commented 9 years ago

I just change your code src/internal/sio_client_impl.cpp line : 568

ctx->set_options(boost::asio::ssl::context::default_workarounds |
                             /*boost::asio::ssl::context::no_sslv2 |*/
                             boost::asio::ssl::context::single_dh_use,ec);
        if(ec)
        {
            cerr<<"Init tls failed,reason:"<< ec.message()<<endl;
        }

is boost::asio::ssl::context::no_sslv2 on Mac can’t build , but I don’t know why !!

can u tell me that reason ? @melode11

eternaltao commented 8 years ago

I'm getting stuck in the problem when I try to connect a "https" or "wss" website.

I did this: /_boost::asio::ssl::context::nosslv2 |/ as you said but it didn't work. (I test it on ubuntu 12.04)

g++ -Wall -g -std=c++0x -o client client.cpp -I../build/include/ -I/usr/include/boost ../build/lib/Release/libboost_system.a ../build/lib/Release/libsioclient.a ../build/lib/Release/libsioclient_tls.a ../build/lib/Release/libboost_random.a -lboost_system -lboost_thread -lpthread

My code:

... 
sio::client h;
    connection_listener l(h);

    h.set_open_listener(std::bind(&connection_listener::on_connected, &l));
    h.set_close_listener(std::bind(&connection_listener::on_close, &l,std::placeholders::_1));
    h.set_fail_listener(std::bind(&connection_listener::on_fail, &l));
    //h.connect("https://192.168.168.24:443");
    h.connect("wss://meshblu.octoblu.com:443/socket.io/");
...

Error reports:

[2015-12-30 16:14:45] [connect] Successful connection
[2015-12-30 16:14:45] [error] handle_read_http_response error: websocketpp.transport:7 (End of File)
[2015-12-30 16:14:52] [connect] Successful connection
[2015-12-30 16:14:54] [error] handle_read_http_response error: websocketpp.transport:7 (End of File)
[2015-12-30 16:15:02] [connect] Successful connection
[2015-12-30 16:15:03] [error] handle_read_http_response error: websocketpp.transport:7 (End of File)
[2015-12-30 16:15:14] [connect] Successful connection
[2015-12-30 16:15:14] [error] handle_read_http_response error: websocketpp.transport:7 (End of File)
[2015-12-30 16:15:32] [connect] Successful connection
[2015-12-30 16:15:32] [error] handle_read_http_response error: websocketpp.transport:7 (End of File)
[2015-12-30 16:15:32] [info] Error getting remote endpoint: system:107 (Transport endpoint is not connected)
rgross2 commented 8 years ago

@forfuns Did you ever get an answer? @melode11 Running the CMake generates an OSX build, how do you generate a iOS build?

nwestbury commented 8 years ago

@rgross2 @forfuns @melode11 I'm still having this issue. Has anyone solved this? Thanks.

CubanAzcuy commented 8 years ago

@nwestbury No, I had to redo large parts of my project to allow for swift version.... Sorry.

mbajaria commented 7 years ago

@eternaltao I facing same error. I am trying to connect https server. [connect] Successful connection [error] handle_read_http_response error: websocketpp.transport:7 (End of File)

Can you please help? Thanks

gytai commented 6 years ago

[connect] Successful connection [error] handle_read_http_response error: websocketpp.transport:7 (End of File)

this problem is also exist...

xuguangxiao commented 5 years ago

@forfuns refer to this: https://stackoverflow.com/questions/15602113/cannot-link-with-boost-in-mac-os-x-with-clang-c11