Skip to content

Can't connect to wss endpoint #425

Closed

Description

@fkaduch

Hello,

I am trying IXWEbSocket sample code and I setup server and client successfully. The client tries to connect to server at wss endpoint "wss://localhost:8008", but I am getting this error from the server:

$./IXWebSocketServer /IXWebSocketServer
WebSocketServer::handleConnection() HTTP status: 400 error: Invalid HTTP method, need GET, got

I am attaching IXWebSocket client and server sample code.

Sample code works well when I use ws endpoint "ws://localhost:8008".

I used also this Javascript client
main_client.docx
main_server.docx
to connect to the IXWebSocket server:

https://www.lddgo.net/en/network/websocket

and it works with ws endpoint "ws://localhost:8008", but not with a wss one "wss://localhost:8008".

I build the library with these options on Ubuntu 20.04 LTS:

$ cmake -DUSE_TLS=1 -DUSE_ZLIB=0 -DUSE_WS=1 -DUSE_TEST=1 -DUSE_OPEN_SSL=1 ..

I appreciate help

Activity

  1. peterphonic commented on Jan 11, 2023

    @peterphonic

    Did you create your key and certificate?

  2. bsergean commented on Nov 17, 2026

    @bsergean
    Collaborator

    I inspected the attached main_server.docx. It constructs and starts a WebSocketServer without enabling TLS on the listener. -DUSE_TLS=1 compiles TLS support; it does not turn each server into a TLS listener. A TLS ClientHello sent to that plain listener is then interpreted as an HTTP request, explaining the “Invalid HTTP method” error.

    Before server.listen(), configure the server certificate/key and enable TLS:

    ix::SocketTLSOptions options;
    options.tls = true;
    options.certFile = "server-cert.pem";
    options.keyFile = "server-key.pem";
    server.setTLSOptions(options);

    For a private/self-signed CA, configure the client's caFile with the issuing CA and use a wss:// hostname covered by the certificate. #654 adds these C++11 examples and clarifies the build-option/listener distinction. Current TLS server/client tests pass with OpenSSL and Mbed TLS, and Network.framework's TLS tests pass as well.

    Closing this configuration issue; if it persists with TLS explicitly configured on the listener, please reopen with the current configuration and version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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