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!
Thanks for posting this. I'm having the same problem. Were you ever able to resolve it? Thanks!