Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error after receiving web socket connection

See original GitHub issue

After a successful web socket connection, I get a TypeError:

centrifuge.js?4f09:1144 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'client')
    at Centrifuge._connectResponse (centrifuge.js?4f09:1144:1)
    at eval (centrifuge.js?4f09:721:1)
  1. Error -
  2. Success connected in network - ,
  3. Line error -

code is on the client:

useEffect(() => {
    const centrifuge = new Centrifuge('ws://localhost:8001/connection/websocket', {
      debug: true,
      getToken: async (ctx) => {
        const response = await WebSocketApi.jwt(ctx)


    // const sub = centrifuge.newSubscription('channel');

    centrifuge.on('connected', function (ctx) {
      console.log('Connected:', ctx)

    centrifuge.on('connecting', function (ctx) {
      console.log('Connecting:', ctx)

    centrifuge.on('disconnected', function (ctx) {
      console.log('Disconnected:', ctx)

    centrifuge.on('error', function (ctx) {
      console.log('Error:', ctx)

    // sub.on('publication', function(ctx) {
    //     console.log('Publication:',;
    // });
    // sub.subscribe();


    return () => centrifuge.disconnect()
  }, [dispatch])


    image: centrifugo/centrifugo:4.0.1
      - ./api/docker/common/centrifugo/config.json:/centrifugo/config.json
    command: centrifugo -c config.json --admin
      CENTRIFUGO_SECRET: centrifugo_secret
      CENTRIFUGO_ADMIN_PASSWORD: centrifugo_admin_password
      CENTRIFUGO_ADMIN_SECRET: centrifugo_admin_secret
      CENTRIFUGO_API_KEY: jPE0aEYwqO5nwXH2omiEQB2A5cIXjcijcjGUuJ2k4jji8DVNNA2IonePfUWDmO1s
      - 8001:8001
        soft: 65535
        hard: 65535
      - traefik-public
      - default
      - traefik.enable=true
      - traefik.http.routers.centrifugo.rule=Host(`centrifugo.localhost`)
      - traefik.http.routers.centrifugo.entryPoints=http


    "port": 8001,
    "engine": "memory",
    "api_key": "secret",
    "allowed_origins": [
    "use_client_protocol_v1_by_default": true,
    "skip_user_check_in_subscription_token": true,
    "proxy_connect_endpoint": "http://api/api/v1/centrifugo/connect",
    "proxy_http_headers": [
    "namespaces": [
            "name": "personal",
            "allow_user_limited_channels": true,
            "allow_subscribe_for_client": true
            "name": "ticket_buying",
            "allow_user_limited_channels": true,
            "allow_subscribe_for_client": true
            "name": "raffle",
            "allow_user_limited_channels": true,
            "allow_subscribe_for_client": true
            "name": "advice_blog",
            "allow_user_limited_channels": true,
            "allow_subscribe_for_client": true
            "name": "transaction",
            "allow_user_limited_channels": true,
            "allow_subscribe_for_client": true
    "allow_user_limited_channels": true,
    "allow_subscribe_for_client": true

proxy_connect_endpoint response:



  • centrifuge-js:3.0.1
  • centrifugo/centrifugo:4.0.1
  • react:18.2.0
  • next:12.2.5

As I understood, the centrifugo itself accepts the response from the server and sends it to the client, but for some reason it does not work for the client, please tell me what I am doing wrong

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

FZambiacommented, Oct 21, 2022

Welcome, hope all working now! Join our community rooms btw (most active in Telegram)

FZambiacommented, Oct 21, 2022

You mean subs? Yes, subs are not appended to ConnectedContext -

Though if you have code like this:

centrifuge.on('subscribed', function (ctx) {
      console.log('Subscribed on server-side channel:', ctx)

– then it will be called for each channel in subs. See

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebSockets - Handling Errors
WebSockets - Handling Errors, Once a connection has been established between the client and the server, an open event is fired from the...
Read more >
WebSocket: error event - Web APIs | MDN
The error event is fired when a connection with a WebSocket has been closed due to an error (some data couldn't be sent...
Read more >
Websocket onerror - how to read error description?
Show activity on this post. The error Event the onerror handler receives is a simple event not containing such information: If the user...
Read more >
Troubleshooting connection issues | Socket.IO
You are trying to reach a plain WebSocket server; The server is not reachable; The client is not compatible with the version of...
Read more >
Error with WebSocket - Microsoft Q&A
The error event is fired when a connection with a WebSocket has been closed due to an error (some data couldn't be sent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found