Skip to content

Mongoose Websocket Server with JavaScript Websocket Client? #1685

Discussion options

You must be logged in to vote

RFC6455 section 3 clearly allows URI paths.
Observe the example code, you control your URIs, you decide where to upgrade. The choice of using /websocket is just a convenience to be able to also serve HTML using a single port (and a single listener). How do you plan to serve that client to the browser ?
If you don't want to serve HTML then just upgrade on any URI, just change

} else if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
if (mg_http_match_uri(hm, "/websocket")) {
// Upgrade to websocket. From now on, a connection is a full-duplex
// Webso…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@efweber999
Comment options

@efweber999
Comment options

@scaprile
Comment options

Answer selected by scaprile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants