Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example server + client fails #7

Open
bjornstromberg opened this issue Jul 3, 2022 · 3 comments
Open

example server + client fails #7

bjornstromberg opened this issue Jul 3, 2022 · 3 comments

Comments

@bjornstromberg
Copy link

bjornstromberg commented Jul 3, 2022

see oatpp/oatpp-websocket#38 (comment) it seems to be the same issue.

I |2022-07-03 22:13:13 1656879193764964| websocket-client:Application Started
 I |2022-07-03 22:13:14 1656879194377704| websocket-client:Connected
 D |2022-07-03 22:13:14 1656879194378063| websocket-client:sending message...
 D |2022-07-03 22:13:14 1656879194379271| [oatpp::web::protocol::websocket::WebSocket::listen()]:Unhandled error occurred. Message='[oatpp::web::protocol::websocket::WebSocket::readFrameHeader()]: Error reading frame header'
 D |2022-07-03 22:13:14 1656879194379349| websocket-client:SOCKET CLOSED!!!

@bjornstromberg
Copy link
Author

well it seems its more of a bad description of what should happen.

client connects to third party api online.

expected a client / server local ping pong

@lganzzzo
Copy link
Member

Hello @bjornstromberg ,

It looks that API key for demo server is expired.
I've updated the API key in the example and it works:

  auto connection = connector->connect("v3/channel_1?api_key=VCXCEuvhGcBDP7XhiJJUDvR1e1D3eiVjgZ9VRiaV&notify_self");

@pedro-vicente
Copy link

pedro-vicente commented May 22, 2023

well it seems its more of a bad description of what should happen.

client connects to third party api online.

expected a client / server local ping pong

The 'client' example can be modified to connect to localhost with the 'server' example with



int local = 1;
  std::string url = "localhost";
  uint16_t port = 8000;
  std::string conn_str = "ws";
  if (!local)
  {
    url = "demo.piesocket.com";
    port = 80;
    conn_str = "v3/channel_1?api_key=oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm&notify_self";
  }

  auto connectionProvider = oatpp::network::tcp::client::ConnectionProvider::createShared({url, port});

  auto connector = oatpp::websocket::Connector::createShared(connectionProvider);

  auto connection = connector->connect(conn_str);

and the examples can be easily build by modifying the main CMake file in /src to have at the end


include_directories(.)

add_library(oatpp-websocket
        oatpp-websocket/src/oatpp-websocket/AsyncConnectionHandler.cpp
        oatpp-websocket/src/oatpp-websocket/AsyncConnectionHandler.hpp
        oatpp-websocket/src/oatpp-websocket/AsyncWebSocket.cpp
        oatpp-websocket/src/oatpp-websocket/AsyncWebSocket.hpp
        oatpp-websocket/src/oatpp-websocket/Config.hpp
        oatpp-websocket/src/oatpp-websocket/ConnectionHandler.cpp
        oatpp-websocket/src/oatpp-websocket/ConnectionHandler.hpp
        oatpp-websocket/src/oatpp-websocket/Connector.cpp
        oatpp-websocket/src/oatpp-websocket/Connector.hpp
        oatpp-websocket/src/oatpp-websocket/Frame.cpp
        oatpp-websocket/src/oatpp-websocket/Frame.hpp
        oatpp-websocket/src/oatpp-websocket/Handshaker.cpp
        oatpp-websocket/src/oatpp-websocket/Handshaker.hpp
        oatpp-websocket/src/oatpp-websocket/SHA1.cpp
        oatpp-websocket/src/oatpp-websocket/SHA1.hpp
        oatpp-websocket/src/oatpp-websocket/Utils.cpp
        oatpp-websocket/src/oatpp-websocket/Utils.hpp
        oatpp-websocket/src/oatpp-websocket/WebSocket.cpp
        oatpp-websocket/src/oatpp-websocket/WebSocket.hpp
)

include_directories(oatpp-websocket/src)

add_executable(client
        example-websocket/client/src/App.cpp
        example-websocket/client/src/WSListener.cpp
        example-websocket/client/src/WSListener.hpp
)

add_executable(server
        example-websocket/server/src/App.cpp
        example-websocket/server/src/AppComponent.hpp
        example-websocket/server/src/websocket/WSListener.cpp
        example-websocket/server/src/websocket/WSListener.hpp
)

target_link_libraries(client oatpp-websocket oatpp)
target_link_libraries(server oatpp-websocket oatpp)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants