Skip to content
  • Use Websockets in own Plugin

    Solved Plugin Development
    4
    0 Votes
    4 Posts
    1k Views
    dogsD
    I still have a question. Everything works fine at the moment. Send data from the client to the server isn't a problem now. But how can I emit a event to all connected clients serverside? Something e.g myPlugin.emit('plugins.publishMessage', {data: "Some data"}, function(err, result) { console.log(result); }); After one hour spending searching different topics and some code I found the solution. Besides the custom clientside Sockets const myPluginSockets = require.main.require('./src/socket.io/plugins'); you have to define the Server Sockets too const myPluginSockets = require.main.require('./src/socket.io/plugins'); const serverSockets = require.main.require('./src/socket.io'); Now you can emit events from server side to the clients: serverSockets.server.sockets.emit('messageReceive', data); to receive the event clientside, you can use following in ur main.js file: socket.on('messageReceive', function(data){ console.log(data); }); Client console output: {msg: "my message"} Maybe I'll write a little Tutorial on this because I am probably not the only one who does not understand it so easily.
  • 0 Votes
    6 Posts
    1k Views
    D
    @pitaj said in How to use websocket notifications from external app?: @reinier-pupo okay so you want to listen for notifications. You essentially want something like this: https://github.com/NodeBB/NodeBB/blob/b46d2f93e64e6546fb295d396b830dcab9f0cbbd/employee monitoring software/public/src/client/header/notifications.js#L25 Yeah, thank you!! Exactly what i was looking for!
  • 0 Votes
    6 Posts
    1k Views
    julianJ
    Definitely would appreciate updates to our documentation so you can help others facing similar problems! Glad you're on your way.
  • 0 Votes
    1 Posts
    1k Views
    Peter-Zoltan KeresztesP
    Hello, I am trying to setup nodebb with haproxy instead of nginx as frontend. Everything seam to be working however I am getting lots of 403 on /socket.io/ requests. frontend http-in mode http bind 0.0.0.0:80 redirect scheme https code 301 if !{ ssl_fc } frontend https-in bind 0.0.0.0:443 ssl crt /etc/letsencrypt/live/test/test.pem http-response set-header strict-transport-security "max-age=31536000; includeSubDomains" http-response set-header Content-Security-Policy "default-src 'self' wss: https: *.startech-rd.tk/*; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://code.jquery.com; style-src 'self' 'unsafe-inline' https:; img-src 'self' https://casper.ghost.org/ https://www.gravatar.com/ data:; font-src 'self' https:" http-response set-header X-XSS-Protection "1; mode=block" http-response set-header X-Content-Type-Options "nosniff" http-response set-header Referrer-Policy "no-referrer" reqadd X-Forwarded-Proto:\ https acl is_websocket hdr(Upgrade) -i WebSocket acl is_websocket path_sub -i /socket.io/ use_backend bk_ws if is_websocket acl acl_comments path_beg -i /comments use_backend comments if acl_comments backend comments mode http balance leastconn timeout connect 1s timeout server 600s timeout queue 600s option redispatch retries 3 acl is_woff capture.req.uri -m sub .woff acl is_ttf capture.req.uri -m sub .ttf acl is_eot capture.req.uri -m sub .eot http-response set-header Cache-Control public if is_eot or is_woff or is_ttf http-response set-header Expires -1 if is_eot or is_woff or is_ttf http-response set-header Pragma cache if is_eot or is_woff or is_ttf cookie nodebb insert indirect nocache secure server node1 10.160.125.81:4567 cookie nodebb_node1 check inter 1000 fastinter 500 rise 2 fall 1 server node2 10.160.125.82:4567 cookie nodebb_node2 check inter 1000 fastinter 500 rise 2 fall 1 backend bk_ws option redispatch balance roundrobin option forwardfor option httpclose server node1 10.160.125.81:4567 maxconn 30000 weight 10 cookie ws_node1 check server node2 10.160.125.82:4567 maxconn 30000 weight 10 cookie ws_node2 check``` I have tried to connect directly without haproxy and the websockets are connecting correctly. However I've seen that using the haproxy the websocket protocol changed from wss to https. Any suggestions on how to fix this?
  • Using CloudFlare with NodeBB

    Tutorials
    106
    15 Votes
    106 Posts
    73k Views
    phenomlabP
    @DownPW I'm not sure it's solely traffic that causes this. I took saw this frequently when I used Cloudflare and it became so bad that I decided to stop using the service altogether. No issues since.
  • 0 Votes
    12 Posts
    8k Views
    L
    @Andi no problem, happy to help
  • 0 Votes
    4 Posts
    3k Views
    yariplusY
    what is the value of uid
  • 0 Votes
    1 Posts
    5k Views
    Y
    Hi folks, I used the 2.4 proxy instructions from the docs. But it's not working correctly for me. I assume because I want the proxy to only work on '/community'. Here's my current setup: I have a proxy here: https://openrct2.com/community (HTTPS) NodeBB actually runs on: http://delia.limetric.com:4567/community/ (just normal HTTP) The proxy itself works great, but socket.io keeps complaining about not being able to connect using websockets: "WebSocket connection to 'wss://openrct2.com/community/socket.io/?EIO=3&transport=websocket&sid=OORktGqFRszzHMQNAAWr' failed: Error during WebSocket handshake: Unexpected response code: 400" Here's a pastebin to my Apache config: http://pastebin.com/UMMadXVR What should I change to my config to make websockets work correctly? Thanks in advance.
  • [SOLVED]socket.io - websocket custom port

    General Discussion
    3
    0 Votes
    3 Posts
    5k Views
    T
    Thank you for your note, @julian I acctually found what I were need. Adding an appropriate string to config.json - solved my problem. "socket.io": { "address": "http://myforum.com:8000" } Thus websocket will use port 8000 on establishing the connection. One of openshift's bottleneck, that held me up. Done
  • 0 Votes
    2 Posts
    3k Views
    barisB
    We just removed it from the ACP, it can be put in config.json now in a socket.io block. https://docs.nodebb.org/en/latest/configuring/config.html
  • [Resolved] Socket UID doesn't match actual UID

    Bug Reports
    4
    0 Votes
    4 Posts
    3k Views
    XiphX
    For some reason socket.example.com/socket.io/1/?t=[a whole bunch of numbers] doesn't set CORS headers half of the time when I start NodeBB, causing any and all WebSocket connections to fail... but I guess that's a socket.io issue, not a NodeBB one.
  • 0 Votes
    2 Posts
    4k Views
    mootzvilleM
    I figured this out finally...I had nginx v1.2 which is what's in the default debian 7 repo. Had to add a new key and some new sources from here: http://nginx.org/en/linux_packages.html#distributions Now on nginx v1.6.2 and it seems to be running fine. From what I read there was no websocket support in nginx <1.3