Skip to content

Instantly share code, notes, and snippets.

@arjunvenkat
Created March 25, 2015 20:12
Show Gist options
  • Select an option

  • Save arjunvenkat/089711002874018232b6 to your computer and use it in GitHub Desktop.

Select an option

Save arjunvenkat/089711002874018232b6 to your computer and use it in GitHub Desktop.
issues setting up repl.it API

One thing I was confused about was what hostname meant in

ReplitClient(hostname, port, language, token)

I assumed it meant the host of my development/production server. I'm using Rails, which is hosted by default in development at localhost:3000. However, when I tried initializing a new client with:

var token = {
    "time_created": "1427169806044",
    "msg_mac": "ub4I1EjJZLtcvtnawuuHoWQF/Ngj26aeBwVfk7anQEI="
  }
var repl = new ReplitClient('localhost', 3000, 'ruby', token);

I got the following error in my Chrome JavaScript console:

WebSocket connection to 'ws://localhost:3000/ws' failed: Error during WebSocket handshake: Unexpected response code: 404

and repl.connect() failed.

However, I did end up getting connected when I used:

var token = {
    "time_created": "1427169806044",
    "msg_mac": "ub4I1EjJZLtcvtnawuuHoWQF/Ngj26aeBwVfk7anQEI="
  }
var repl = new ReplitClient('trial.repl.it', 80, 'ruby', token);

And I was able to have code correctly evaluated by the server. But, every few seconds, the following error would show up in my console:

Uncaught (in promise) Error: Not connected yet {stack: (...), message: "Not connected yet"}

And I wasn't able to use .write(str) without getting an error.

Do you have any idea what I might be doing wrong?

Thanks!

@tryenc
Copy link

tryenc commented Jan 31, 2016

Thanks for posting this. I'm having the same problem. Were you ever able to resolve it? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment