Socketio Error after Fresh Install

Keep getting this error on browser console. This is fresh install on Ubuntu 14.04 digital ocean.

WebSocket connection to 'ws://xx.x.x.x/socket.io/?EIO=3&transport=websocket&sid=XiLrM8s06RlLiiDlAAAC' failed: Error during WebSocket handshake: Unexpected response code: 400

I followed this Regenerate Production Config Files (ERPNext) · frappe/bench Wiki · GitHub, but no luck…

Got below error when running bench setup socketio::

npm http 304 https://registry.npmjs.org/parsejson/0.0.1
/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying t        o load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.j        s:431:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:        12)
gyp ERR! System Linux 3.13.0-57-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/vef1/frappe-bench/node_modules/socket.io/node_modules/engine.        io/node_modules/ws/node_modules/utf-8-validate
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm WARN optional dep failed, continuing utf-8-validate@1.2.1
/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying t        o load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.j        s:431:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:        12)
gyp ERR! System Linux 3.13.0-57-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/vef1/frappe-bench/node_modules/socket.io/node_modules/engine.        io/node_modules/ws/node_modules/bufferutil
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm WARN optional dep failed, continuing bufferutil@1.2.1
npm http 200 https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz
npm http GET https://github.com/component/global/archive/v2.0.1.tar.gz

> utf-8-validate@1.2.1 install /home/vef1/frappe-bench/node_modules/socket.io/no        de_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_m        odules/utf-8-validate
> node-gyp rebuild


> bufferutil@1.2.1 install /home/vef1/frappe-bench/node_modules/socket.io/node_m        odules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modul        es/bufferutil
> node-gyp rebuild

/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying t        o load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.j        s:431:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:        12)
gyp ERR! System Linux 3.13.0-57-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/vef1/frappe-bench/node_modules/socket.io/node_modules/socket.        io-client/node_modules/engine.io-client/node_modules/ws/node_modules/utf-8-valid        ate
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm WARN optional dep failed, continuing utf-8-validate@1.2.1
/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying t        o load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.j        s:431:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:        12)
gyp ERR! System Linux 3.13.0-57-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/vef1/frappe-bench/node_modules/socket.io/node_modules/socket.        io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm WARN optional dep failed, continuing bufferutil@1.2.1
npm http 200 https://github.com/component/global/archive/v2.0.1.tar.gz
cookie@0.2.3 node_modules/cookie
1 Like

You might not have node installed. Try reading: Installing Node.js via package manager | Node.js

@anand node was installed but the error still persists, keep getting these in the console…

WebSocket connection to 'ws://xx.x.x.x/socket.io/?EIO=3&transport=websocket&sid=XiLrM8s06RlLiiDlAAAC' failed: Error during WebSocket handshake: Unexpected response code: 400

http://xx.xx.xxx.xxx/socket.io/?EIO=3&transport=polling&t=1447166954087-8&sid=BvEfQ33cR3RAov45AAAD Failed to load resource: the server responded with a status of 400 (Bad Request)

The system is working but sometimes the loading is long… What does this error mean? What’s the effect?

Tks

sudo supervisorctl status 

frappe:frappe-web                RUNNING    pid 1506, uptime 0:19:34
frappe:frappe-worker             RUNNING    pid 1499, uptime 0:19:34
frappe:frappe-workerbeat         RUNNING    pid 1515, uptime 0:19:34
node-socketio                    RUNNING    pid 1539, uptime 0:19:33
redis-async-broker               RUNNING    pid 1521, uptime 0:19:34
redis-cache                      RUNNING    pid 1563, uptime 0:19:33

Everything seems working fine…

Can you try removing/purging node and npm and install node from node source, Node.js — Installing Node.js via package manager ?

After you install, restart using,

sudo supervisorctl restart node-socketio

@pdvyas I removed nodejs then reinstalled it then restarted node-socketio then rebooted server…
Now I’m getting this:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

@pdvyas The error seemed to be gone for a while after removed and reinstalled nodejs. but now the error is keep getting back…Do you know why?

/frappe-bench$ sudo supervisorctl status
frappe:frappe-web                RUNNING    pid 2928, uptime 1 day, 1:00:20
frappe:frappe-worker             RUNNING    pid 2927, uptime 1 day, 1:00:20
frappe:frappe-workerbeat         RUNNING    pid 2936, uptime 1 day, 1:00:20
node-socketio                    RUNNING    pid 1627, uptime 1 day, 1:16:34
redis-async-broker               RUNNING    pid 1626, uptime 1 day, 1:16:34
redis-cache                      RUNNING    pid 1628, uptime 1 day, 1:16:34

Nope, but I think nginx error logs might have a clue.

I ran bench setup socketio again and now the error is clear. Tks

1 Like

@pdvyas the error is keep getting back…but if I restarted the server the error is gone.

I checked node-socketio.log, seems this causes the error. Do you know what is this?

header: 
      { server: 'nginx/1.4.6 (Ubuntu)',
        date: 'Tue, 17 Nov 2015 03:16:57 GMT',
        'content-type': 'text/html; charset: utf-8',
        'content-length': '6234',
        connection: 'close',
        'x-page-name': 'message',
        'x-from-cache': 'False',
        'set-cookie': [Object] },
     statusCode: 403,
     status: 403,
     statusType: 4,
     info: false,
     ok: false,
     redirect: false,
     clientError: true,
     serverError: false,
     error: 
      { [Error: cannot GET /api/method/frappe.async.can_subscribe_doc (403)]
        status: 403,
        text: '<!DOCTYPE html>\n<!-- Built on Frappe. https://frappe.io/ -->\n<html lang="en">\n<head>\n\t<meta charset="utf-8">\n\t<meta name="viewport" content="width=device-width, initial-scale=1.0">\n\t<title>Server Error</title>\n\t<meta name="generator" content="frappe">\n\t<script type="text/javascript"\n\t\tsrc="/assets/frappe/js/lib/jquery/jquery.min.js"></script>\n\t<script type="text/javascript"\n\t\tsrc="/assets/js/frappe-web.min.js"></script>\n\n    \n\t<link rel="shortcut icon"\n\t\thref="/assets/erpnext/images/favicon.png"\n\t\ttype="image/x-icon">\n\t<link rel="icon"\n\t\thref="/assets/erpnext/images/favicon.png"\n\t\ttype="image/x-icon">\n    \n\n\t\t\n\t\t<link type="text/css" rel="stylesheet" href="/assets/frappe/css/bootstrap.css">\n\t\t<link type="text/css" rel="stylesheet" href="/website_theme.css">\n\t\t<link type="text/css" rel="stylesheet" href="/assets/css/frappe-web.css">\n\t\t<link type="text/css" rel="stylesheet" href="/assets/erpnext/css/website.css">\n\t\t\t<style data-html-block="style"></style></head>\n<body data-path="message">\n\t<div class="offcanvas-container">\n\t\t<div class="offcanvas">\n\t\t\t<div class="offcanvas-main-section">\n\t\t\t\t<div>\n\t\t\t\t\t\t<header>\n\t<nav class="navbar navbar-default navbar-main" role="navigation">\n\t\t<div class="container">\n\t\t\t<div class="navbar-header">\n\t\t\t\t<a class="navbar-brand ellipsis" href="/">\n\t\t\t\t\t<span>SLM Parts</span>\n\t\t\t\t</a>\n\t\t\t\t<a class="pull-right toggle-sidebar visible-xs">\n\t\t\t\t\t<i class="octicon octicon-three-bars"></i>\n\t\t\t\t</a>\n\t\t\t</div>\n\t\t\t<div class="hidden-xs">\n\t\t\t\t\n\t\t\t\t\n<ul class="nav navbar-nav navbar-right">\n\t<!-- post login tools -->\n\n<li class="dropdown logged-in" id="website-post-login"\n\tdata-label="website-post-login" style="display: none">\n\t<a href="#" class="dropdown-toggle" data-toggle="dropdown">\n\t\t<span class="avatar avatar-small user-image-wrapper"><img class="user-image"/></span>\n\t\t<span class="visible-xs full-name"></span>\n\t</a>\n    <ul class="dropdown-menu" role="menu"><li data-label="My Account" \n\t\t\t><a href="/me" \n\t\t\t\t\trel="nofollow">\n\t\t\t\t\tMy Account\n\t\t\t\t</a></li><li \n\t\t\t class="divider" ></li><li data-label="Logout" \n\t\t\t><a href="/?cmd=web_logout" \n\t\t\t\t\trel="nofollow">\n\t\t\t\t\tLogout\n\t\t\t\t</a></li></ul>\n</li>\n\n<li class="btn-login-area"><a href="/login">Login</a></li>\n\n\n</ul>\n\n\t\t\t\t\n\t\t\t</div>\n\t\t</div>\n\t</nav>\n</header>\n<script>$(function() { $(\'.dropdown-toggle\').dropdown(); });</script><div class="hero-and-content"><div data-html-block="hero">\n                                \n                            </div>\n                            <div class="container" data-html-block="content">\n                            <div class="page-container" id="page-message" data-path="feed"\n    >\n\t<div class="page-content">\n    \t<div class="page-content-wrapper">\n            <div class="row">\n                <div class="col-sm-8">\n            \t\t<div class="page-header-block" data-html-block="header"><h1>Server Error</h1></div>\n                </div>\n                <div class="col-sm-4">\n            \t\t<div class="page-header-actions-block" data-html-block="header-actions"></div>\n                </div>\n            </div>\n    \t\t<div class="page-breadcrumbs" data-html-block="breadcrumbs"></div>\n    \t    <div class="page-content-block">\n<!-- no-sidebar -->\n<div class="message-content" style="min-height: 200px;">\n\t<div>\n\t\t<pre>Traceback (innermost last):\n  File "/home/vef1/frappe-bench/apps/frappe/frappe/app.py", line 70, in application\n    response = frappe.api.handle()\n  File "/home/vef1/frappe-bench/apps/frappe/frappe/api.py", line 50, in handle\n    return frappe.handler.handle()\n  File "/home/vef1/frappe-bench/apps/frappe/frappe/handler.py", line 75, in handle\n    execute_cmd(cmd)\n  File "/home/vef1/frappe-bench/apps/frappe/frappe/handler.py", line 109, in execute_cmd\n    ret = frappe.call(method, **frappe.form_dict)\n  File "/home/vef1/frappe-bench/apps/frappe/frappe/__init__.py", line 777, in call\n    return fn(*args, **newargs)\n  File "/home/vef1/frappe-bench/apps/frappe/frappe/async.py", line 207, in can_subscribe_doc\n    raise PermissionError()\n PermissionError\n</pre>\n\t</div>\n</div>\n</div>\n    \t</div>\n\t</div>\n</div>\n                            </div>\n                        \n                    </div>\n\t\t\t\t\t<footer class="page-footer">\n\t\t\t\t\t\t<div class="container" data-html-block="footer"></div>\n\t\t\t\t\t</footer>\n\t\t\t\t</div>\n\t\t\t\t<div><footer class="web-footer">\n\t<section class="footer-links">\n\t\t<div class="container">\n\t\t\t<div class="row">\n\t\t\t\t<div class="col-xs-9 web-footer-menu">\n\t\t\t\t\t<ul class="list-inline">\n\t\t\t\t\t\t\n\t\t\t\t\t</ul>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class="row">\n\t\t\t\t<div class="col-sm-8">\n\t\t\t\t\t<div class="web-footer-copyright text-muted small">&copy; VEF Consulting Indonesia</div>\n\t\t\t\t\tManaged By Jonathan F.Lie\n\t\t\t\t</div>\n\t\t\t\t<div class="col-sm-4 text-right">\n\t\t\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t<div class="text-right footer-powered">\n\t\t\t\t\t\n\t\t\t\t\t\t<!-- blank -->\n\t\t\t\t\t\n                    </div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</section>\n\t<section>\n\t\t\n\t</section>\n</footer></div>\n\t\t\t</div>\n\t\t\t<div class="modal-backdrop offcanvas-main-section-overlay"></div>\n\t\t\t<div class="sidebar sidebar-right visible-xs">\n\t\t\t\t<div class="sidebar-navbar-items">\n\t\t\t\t\t\n<ul class="nav navbar-nav navbar-right">\n\t<!-- post login tools -->\n\n<li class="dropdown logged-in" id="website-post-login"\n\tdata-label="website-post-login" style="display: none">\n\t<a href="#" class="dropdown-toggle" data-toggle="dropdown">\n\t\t<span class="avatar avatar-small user-image-wrapper"><img class="user-image"/></span>\n\t\t<span class="visible-xs full-name"></span>\n\t</a>\n    <ul class="dropdown-menu" role="menu"><li data-label="My Account" \n\t\t\t><a href="/me" \n\t\t\t\t\trel="nofollow">\n\t\t\t\t\tMy Account\n\t\t\t\t</a></li><li \n\t\t\t class="divider" ></li><li data-label="Logout" \n\t\t\t><a href="/?cmd=web_logout" \n\t\t\t\t\trel="nofollow">\n\t\t\t\t\tLogout\n\t\t\t\t</a></li></ul>\n</li>\n\n<li class="btn-login-area"><a href="/login">Login</a></li>\n\n\n</ul>\n\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\n\t<!-- js should be loaded in body! -->\n\t<script type="text/javascript" src="/website_script.js"></script>\n\t<script type="text/javascript" src="/assets/js/erpnext-web.min.js"></script>\n\t\t<script data-html-block="script_lib" data-path="message"></script>\n\t\t<script data-html-block="script"></script>\n\n\t<!-- csrf_token --></body>\n</html>',
        method: 'GET',
        path: '/api/method/frappe.async.can_subscribe_doc' },
     accepted: false,
     noContent: false,
     badRequest: false,
     unauthorized: false,
     notAcceptable: false,
     forbidden: true,
     notFound: false,
     type: 'text/html',
     setEncoding: [Function: bound ],
     redirects: [] },
  status: 403 }

Is this still giving error?

@anand yes. It’s gone if server is restarted. But the error is going back after some time…from the error log its seemed related of async task…

Do you have any idea? Tks

From what I recall, I had fixed one such issue of doc_subscribe sometime back. Maybe you are not using the latest version?

I’m using latest version…v6.10.2

From the error log I think this is the cause:

You need to check both node-socketio.error.log and node-socketio.log

Still getting this error on browser console…already using latest v6.12. I’ve purged, reinstalled nodejs package manager but doesn’t work…

Error: Cannot find module './lib/'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/home/vef1/frappe-bench/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/index.js:2:18)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
module.js:339
    throw err;
    ^

listening on *:3000
listening on *:3000
listening on *:3000
listening on *:3000
listening on *:3000
listening on *:3000
listening on *:3000
listening on *:3000
listening on *:3000
listening on *:3000

I disabled async then the error in the console is now gone… What’s the effect? Is this normal?