pusher / pusher-js

Pusher Javascript library
http://pusher.com
MIT License
2.11k stars 374 forks source link

Keep getting "Invalid channel name" #684

Closed herzaso closed 1 year ago

herzaso commented 1 year ago

Using version 5.1.2 in node in the server (v18.12.1), I get this error: Error: Invalid channel name: '1673738400000'. I'm using the same code from https://pusher.com/docs/channels/getting_started/javascript/#trigger-events-from-your-server According to the documents, numbers are permitted in channel name, so I expected it to work

benw-pusher commented 1 year ago

Could you share the code that receives this error? When testing with channel = pusher.subscribe('1673738400000') I do not receive the error.

herzaso commented 1 year ago

The error is in the server:

/srb-api/node_modules/pusher/lib/pusher.js:20
    throw new Error("Invalid channel name: '" + channel + "'")
    ^

Error: Invalid channel name: '1673738400000'
    at validateChannel (/srb-api/node_modules/pusher/lib/pusher.js:20:11)
    at Pusher.trigger (/srb-api/node_modules/pusher/lib/pusher.js:220:5)
    at broadcast (file:///srb-api/api.js:93:17)
    at levelStart (file:///srb-api/api.js:138:3)
    at Timeout._onTimeout (file:///srb-api/api.js:224:42)
    at listOnTimeout (node:internal/timers:564:17)
    at process.processTimers (node:internal/timers:507:7)

Node.js v18.12.1

pusher v5.1.2

benw-pusher commented 1 year ago

Thanks for the update - this issue was raised on the JS lib and not the node-js lib, hence my confusion. I can see the offending code in the library, will investigate further and get back to you.

herzaso commented 1 year ago

Thanks @benw-pusher. I just noticed that this issue was fixed. I will test it on the next release.

benw-pusher commented 1 year ago

@herzaso the issue wasn't fixed - I closed the PR as I had a misunderstanding. I am still investigating.

benw-pusher commented 1 year ago

Apologies for the delay here! I am unable to replicate this, the following code works well: pusher.trigger('1673738400000', 'my-event', "{'hi':'hello'}")

Do you know if the channel name is using different encoding at all? I you copy the above code and run does it work as expected?

herzaso commented 1 year ago

Thanks @benw-pusher , I'm afraid that I don't use that code anymore so I can't verify if it's working or not. Feel free to close this issue if you think it was resolved

benw-pusher commented 1 year ago

Thanks @herzaso , i'll close off but if you go back to this and encounter the issue once again feel free to get in touch at https://support.pusher.com/hc/en-us/requests/new