Skip to content

Error reading frame header error on sendOneFrameText call #38

Description

@rhard

I have a strange error for one of the users which I cannot debug as I can't reproduce it locally. Basically, the WS connection started normally and can receive messages with no problem. However, when for the first time the message needs to be sent by calling sendOneFrameText, I have an immediate error in the listen() loop. Next you can find the log and the WS client implementation. Note the short time between sendOneFrameText call and the error, so there shouldn't be any response yet from the server.

Do you have an idea, what can it be? For most of the users, the code is working without any problem.

OATPP Version 1.3.0

[2022-05-20 17:32:22.570] [scp] [debug] websocket-client sending message 1...
[2022-05-20 17:32:22.570] [scp] [debug] websocket-client sending message 2...
[2022-05-20 17:32:22.570] [scp] [debug] websocket-client sending message 3...
[2022-05-20 17:32:22.572] [scp] [debug] [oatpp::web::protocol::websocket::WebSocket::listen()] Unhandled error occurred. Message='[oatpp::web::protocol::websocket::WebSocket::readFrameHeader()]: Error reading frame header'
[2022-05-20 17:32:22.572] [scp] [debug] websocket-client SOCKET CLOSED!!!
  auto wsConnection = connector->connect(signedUrl.c_str());
  ws = oatpp::websocket::WebSocket::createShared(wsConnection, true /* maskOutgoingMessages must be true for clients */);
  ws->setListener(std::make_shared<WSListener>(shared_from_this(), socketWriteMutex));

  m_wsPingTimer.enable();

  std::thread thread([&]() {
      ws->listen();
      m_wsPingTimer.disable();
      OATPP_LOGD(TAG, "SOCKET CLOSED!!!")
  });

  while (m_wsPingTimer.wait_for(std::chrono::minutes(WS_PING_TIMEOUT_MIN))) {
      OATPP_LOGD(TAG, "sending message 1...")
      std::lock_guard<std::mutex> lock(socketWriteMutex);
      auto ns = WSMessage::createShared();
      ns->action = "ping";
      auto jsonObjectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared();
      oatpp::String jsonq = jsonObjectMapper->writeToString(ns);
      OATPP_LOGD(TAG, "sending message 2...")
      ws->sendOneFrameText(jsonq);
      OATPP_LOGD(TAG, "sending message 3...")
  }

  ws->sendClose();

  thread.join();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions