[Libwebsockets] HS: WS upgrade response not 101

AL al at cyberversion.com
Fri Apr 5 14:06:32 CEST 2019


Noe, it did not work. This is the setup.

char inputURL[300] = "ws://127.0.0.1:9001";
     int inputPort = 9001;

     struct lws_context_creation_info ctxCreationInfo;
     struct lws_client_connect_info clientConnectInfo;
     struct lws_context *ctx;

     struct lws *wsiTest
     const char *urlProtocol, *urlTempPath; // the protocol of the URL, 
and a temporary pointer to the path
     char urlPath[300]; // The final path string

     // Set both information to empty and allocate it's memory
     memset(&ctxCreationInfo, 0, sizeof(ctxCreationInfo));
     memset(&clientConnectInfo, 0, sizeof(clientConnectInfo));

     clientConnectInfo.port = inputPort; // Set the client info's port 
to the input port

     if (lws_parse_uri(inputURL, &urlProtocol, 
&clientConnectInfo.address, &clientConnectInfo.port, &urlTempPath))
     {
         printf("Couldn't parse URL\n");
     }

     // Fix up the urlPath by adding a / at the beginning, copy the temp 
path, and add a \0 at the end
     urlPath[0] = '/';
     strncpy(urlPath + 1, urlTempPath, sizeof(urlPath) - 2);
     urlPath[sizeof(urlPath) - 1] = '\0';

     clientConnectInfo.path = urlPath; // Set the info's path to the 
fixed up url path

     ctxCreationInfo.port = CONTEXT_PORT_NO_LISTEN; // We don't want 
this client to listen
     ctxCreationInfo.protocols = protocols; // Use our protocol list
     ctxCreationInfo.gid = -1; // Set the gid and uid to -1, isn't used much
     ctxCreationInfo.uid = -1;
     ctxCreationInfo.extensions = extensions; // Use our extensions list

     // Create the context with the info
     ctx = lws_create_context(&ctxCreationInfo);
     if (ctx == NULL)
     {
         printf("Error creating context\n");
         return 1;
     }

     // Set up the client creation info
     clientConnectInfo.context = ctx; // Use our created context
     clientConnectInfo.ssl_connection = 0; // Don't use SSL for this test
     clientConnectInfo.host = clientConnectInfo.address; // Set the 
connections host to the address
     clientConnectInfo.origin = clientConnectInfo.address; // Set the 
conntections origin to the address
     clientConnectInfo.ietf_version_or_minus_one = -1; // IETF version 
is -1 (the latest one)
     clientConnectInfo.protocol = protocols[PROTOCOL_TEST].name; // We 
use our test protocol
     clientConnectInfo.pwsi = &wsiTest; // The created client should be 
fed inside the wsi_test variable

     clientConnectInfo.ssl_connection |= LCCSCF_PIPELINE;

     printf("Connecting to %s://%s:%d%s \n\n", urlProtocol, 
clientConnectInfo.address, clientConnectInfo.port, urlPath);

     // Connect with the client info
     lws_client_connect_via_info(&clientConnectInfo);

Andy Green wrote on 05-Apr-19 6:48 PM:
> On 05/04/2019 17:39, AL wrote:
>
> I guess it finds this confusing.
>
>> Connection: close, Upgrade
>
> If you set, on your client connection info
>
>     i->ssl_connection |= LCCSCF_PIPELINE;
>
> it should remove the "close," part it doesn't like.
>
> -Andy

-- 
Robin


More information about the Libwebsockets mailing list