ssbc / ssb-peer-invites

A new ssb invite system to create invites without having a pub
MIT License
26 stars 2 forks source link

Getting an empty error when calling openInvite sometimes #26

Open Powersource opened 4 years ago

Powersource commented 4 years ago
failed to use invite: {} 

console.error | @ | base.html:19
-- | -- | --
  | (anonymous) | @ | /home/me/prj/ssb/pat…/invite/sheet.js:56
  | (anonymous) | @ | /home/me/prj/ssb/pat…invite/invite.js:39
  | _requests.<computed> | @ | /home/me/prj/ssb/pat…-stream/index.js:38
  | PacketStream._onrequest | @ | /home/me/prj/ssb/pat…stream/index.js:151
  | PacketStream.write | @ | /home/me/prj/ssb/pat…stream/index.js:134
  | (anonymous) | @ | /home/me/prj/ssb/pat…pc/pull-weird.js:56
  | (anonymous) | @ | /home/me/prj/ssb/pat…m/sinks/drain.js:24
  | (anonymous) | @ | /home/me/prj/ssb/pat…roughs/filter.js:17
  | (anonymous) | @ | /home/me/prj/ssb/pat…-codec/index.js:111
  | drain | @ | /home/me/prj/ssb/pat…-reader/index.js:39
  | more | @ | /home/me/prj/ssb/pat…-reader/index.js:55
  | reader.read | @ | /home/me/prj/ssb/pat…-reader/index.js:99
  | (anonymous) | @ | /home/me/prj/ssb/pat…-codec/index.js:104
  | drain | @ | /home/me/prj/ssb/pat…-reader/index.js:39
  | more | @ | /home/me/prj/ssb/pat…-reader/index.js:55
  | (anonymous) | @ | /home/me/prj/ssb/pat…-reader/index.js:66
  | drain | @ | /home/me/prj/ssb/pat…stream/index.js:126
  | (anonymous) | @ | /home/me/prj/ssb/pat…stream/index.js:135
  | emit | @ | events.js:200
  | addChunk | @ | _stream_readable.js:294
  | readableAddChunk | @ | _stream_readable.js:275
  | Readable.push | @ | _stream_readable.js:210
  | onStreamRead | @ | internal/stream_base_commons.js:166

(sorry for the bad stacktrace, electron really doesn't want me to copy paste it properly apparently) (also the failed to use invite: part is mine, the {} is the err from peer-invites)

The most likely reason for this error is that the invite msg is still only in the inviter's db (I created it using browser stuff and the replication is a bit inconsistent there) and I guess at least the pub needs to have the msg for this not to error. It makes sense that it errors but a more clarifying error would be nice (especially as we'd show that to users).

Powersource commented 4 years ago

Code is here https://github.com/ssbc/patchwork/pull/1068/files

Powersource commented 4 years ago

Ok hmm, now I think the message has been gossiped but I'm still getting the same error.

Powersource commented 4 years ago

Ok looked in the server process logs and found this

WebSocket connection to 'wss://localhost/between-two-worlds.dk:8989' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

and the invite looks partly like this ...a256,,wss:between-two-worlds.dk:8989~shs:lbocEW...

Does it accidentally turn the wss address into a local relative address or are wss links supposed to look like that?

In my conn.json the links look like ws://asdf... so I tried changing the invite to look like that and I got this error instead which looks a bit better

WebSocket connection to 'ws://between-two-worlds.dk:8989/' failed: Connection closed before receiving a handshake response

Am I wrong in assuming ws==wss? And could the invite looking like this be a bug in browser-demo (where I generated the invite) @arj03 ?

arj03 commented 4 years ago

@Powersource wss is web sockets over SSL and should be used for between-two-worlds.dk

I have just checked and wss:between-two-worlds.dk:8989~shs:lbocEWqF2Fg6WMYLgmfYvqJlMfL7hiqVAV6ANjHWNw8=.ed25519

works fine from my browser. So maybe something with the patchwork and ssb-ws?

arj03 commented 4 years ago

But this wss://localhost/between-two-worlds.dk is all wrong ;) Don't know how that localhost got it there?

Powersource commented 4 years ago

As I noted in the other issue, adding // to the invite so the server's address starts with wss://betw... instead of wss:betw... made it work I think

Powersource commented 4 years ago

Related https://github.com/ssbc/multiserver/issues/58 , I think