Skip to content
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

Socket is not a constructor #83

Closed
sturatcliffe opened this issue Dec 5, 2020 · 2 comments
Closed

Socket is not a constructor #83

sturatcliffe opened this issue Dec 5, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@sturatcliffe
Copy link

Bug report

Describe the bug

When following the node example in this repo, I'm receiving the following error on the socket.connect() line:

"TypeError: Socket is not a constructor"

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Follow the example here:

https://github.com/supabase/realtime/blob/master/examples/node-js/src/server.js

Use an app.supabase.io hosted API URL for the process.env.REALTIME_URL variable.

Expected behavior

The socket should connect successfully.

System information

  • OS: Windows 10
  • Browser (if applies) N/A
  • Version of realtime-js: 1.0.6
  • Version of Node.js: 14.15.0

Additional context

I'm assuming that if we're using app.supabase.io to host our DB and API, we should be able to use that to connect the realtime-js client to rather than self hosting the realtime API using docker as explained in the examples?

@sturatcliffe sturatcliffe added the bug Something isn't working label Dec 5, 2020
@w3b6x9
Copy link
Member

w3b6x9 commented Dec 6, 2020

@sturatcliffe I think the Node example requires you to run the Realtime server locally by following the instructions here: https://github.com/supabase/realtime#server-set-up. It'll run on port 4000 by default so you don't need to pass in REALTIME_URL env var.

app.supabase.io points to the hosted version of your projects on Supabase which makes it easy for you to watch and get notifications for db changes without having to interface with supabase/realtime and supbase/realtime-js directly. You can refer to the documentation here: https://supabase.io/docs/client/initializing and https://supabase.io/docs/client/subscribe to get started.

Hope that helps!

@sturatcliffe
Copy link
Author

@w3b6x9 ah OK - I couldn't find any confirmation anywhere but I was guessing the realtime server was bundled in with the hosting on app.supabase.io.

I first tried listening for updates using the supabase-js client from a node server, as it's isomorphic so I wondered if that would work, but I couldn't seem to get it to listen for updates in realtime. Fetching data on the server was fine, but realtime updates didn't seem to fire.

However, I've just tried again and got it working......it helps if you actually add the .subscribe() call which I evidently forgot the first time!

Apologies for this issue, and thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants