New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uWebSockets and FreeBSD #7710

nanaya opened this Issue Jun 2, 2018 · 3 comments


None yet
3 participants

nanaya commented Jun 2, 2018

I don't know how much you guys care about FreeBSD compatibility, but switching to uws caused streaming server to stop working because it doesn't support FreeBSD.

            throw new Error('Compilation of µWebSockets has failed and there is no pre-compiled binary ' +

Error: Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a supported C++11 compiler and reinstall the module 'uws'.

Thankfully it seems to be still mostly compatible with the original ws module so switching back to it and updating one deprecation fixes it (or at least seems to fix it, haven't done extensive test).

I imagine something like OS check to figure out which websocket module to use would allow using best available websocket module for each OSes.

The diff looks like something like this (ignore fs import which I'm using to listen to socket file instead of ip address).

diff --git a/streaming/index.js b/streaming/index.js
index 4eaf66865..60962fd87 100644
--- a/streaming/index.js
+++ b/streaming/index.js
@@ -7,8 +7,9 @@ const redis = require('redis');
 const pg = require('pg');
 const log = require('npmlog');
 const url = require('url');
-const WebSocket = require('uws');
+const WebSocket = require('ws');
 const uuid = require('uuid');
+const fs = require('fs');

 const env = process.env.NODE_ENV || 'development';

@@ -503,8 +504,11 @@ const startWorker = (workerId) => {

   const wss = new WebSocket.Server({ server, verifyClient: wsVerifyClient });

-  wss.on('connection', ws => {
-    const req      = ws.upgradeReq;
+  wss.on('connection', (ws, req) => {
+    // stolen from
+    if (ws.upgradeReq === undefined) {
+        ws.upgradeReq = req;
+    }
     const location = url.parse(req.url, true);
     req.requestId  = uuid.v4();
     req.remoteAddress = ws._socket.remoteAddress;

This comment has been minimized.


ignisf commented Jun 2, 2018

Hey, are you sure it's due to lack of FreeBSD support and not because the current uws dep version does not support node 10? Could you check the build log?


This comment has been minimized.


nightpool commented Jun 2, 2018

closing as dupe of #6853/#7448 (tracking issue for node 10 support)

@nightpool nightpool closed this Jun 2, 2018


This comment has been minimized.

nanaya commented Jun 2, 2018

Thanks, that looks like it. Though seems like there's different error when building uws 10.x on node 8/10 on freebsd at the moment.

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