zhaojh329/libuwsc

Invalid header error

manibharathytu opened this issue · 2 comments

I replaced example.c url with this.
ws://www.bitmex.com/realtime

When I run, it gives the following error
(example.c:91) onerror:2: Invalid header

I'm able to connect to the same url with javascript in browser.
var ws = new WebSocket('ws://www.bitmex.com/realtime');

wss://echo.websocket.org - This url is working good from example.c

qaxl commented

Hello. Could you possibly provide snippet and whole error? Thank you. 👍

@U59


int main(int argc, char **argv)
{
	const char *url = "ws://www.bitmex.com/realtime";
    struct ev_loop *loop = EV_DEFAULT;
    struct ev_signal signal_watcher;
	int ping_interval = 10;	/* second */
    struct uwsc_client *cl;
	int opt;

    while ((opt = getopt(argc, argv, "u:P:")) != -1) {
        switch (opt) {
        case 'u':
            url = optarg;
            break;
		case 'P':
			ping_interval = atoi(optarg);
			break;
        default: /* '?' */
            usage(argv[0]);
        }
    }

	uwsc_log_info("Libuwsc: %s\n", UWSC_VERSION_STRING);

    cl = uwsc_new(loop, url, ping_interval, NULL);
    if (!cl)
        return -1;

	uwsc_log_info("Start connect...\n");

    cl->onopen = uwsc_onopen;
    cl->onmessage = uwsc_onmessage;
    cl->onerror = uwsc_onerror;
    cl->onclose = uwsc_onclose;

    ev_signal_init(&signal_watcher, signal_cb, SIGINT);
    ev_signal_start(loop, &signal_watcher);

    ev_run(loop, 0);

    free(cl);
    
    return 0;
}

This is the main function. If you want I can paste the full code. But it is just the /example/example.c file in this repository with the url changed

Error :
http://i.imgur.com/RlsocWl.png