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

Fix VrpcRemote documentation/behaviour #39

Open
filipomar opened this issue Mar 10, 2021 · 0 comments
Open

Fix VrpcRemote documentation/behaviour #39

filipomar opened this issue Mar 10, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@filipomar
Copy link

Summary

The documentation of the events emitted by the VrpcRemote seems to:

  • deviate from the actual behaviour of the VrpcRemote
  • be a bit unclear as to how it behaves in some usecases/flows.

The events are mentioned below are connected, connect, reconnect, close, offline, end, instanceNew, instanceGone and error.

The connected, connect, reconnect, close, offline and end events

const remote = new VrpcRemote({
    broker: `wss:${window.location.host}/mqtt`,
    domain: 'internal.cybus',
    bestEffort: true,
    username,
    password
})

console.group('Setting up listeners')
remote.on('connected', () => console.log('Event fired: connected'))
remote.on('connect', () => console.log('Event fired: connect'))
remote.on('reconnect', () => console.log('Event fired: reconnect'))
remote.on('close', () => console.log('Event fired: close'))
remote.on('offline', () => console.log('Event fired: offline'))
remote.on('end', () => console.log('Event fired: end'))
console.groupEnd()

console.group('Connecting...')
await remote.connect()
console.groupEnd()

console.group('Ending...')
await remote.end()
console.groupEnd()

console.group('Connecting again...')
await remote.connect()
console.groupEnd()

Expected Behavior

Setting up listeners
Connecting...
    Event fired: connect
    Event fired: connected
Ending...
    Event fired: end
    Event fired: close
Connecting again...
    Event fired: reconnect
    Event fired: connect
    Event fired: connected

Actual

Setting up listeners
Connecting...
    Event fired: connect
Ending...
Connecting again...
    Event fired: connect

Furthermore, it's not clear to me when the offline event should be fired, is it along with the close event? Or is it when there is a external reason for the disconnection? Which then would be brought along side an error event?

Documentation used to base these assumptions:

Connected event
Connect event
Close event
End event
Offline event
Reconnect event

Instance New and Instance Gone events
Instance New and Instance Gone are fired once per instance type, but only for the first connection.

Before the code block below was executed, the instances called docker, core, testserviceb and servicesCatalog were created, but I think they are not relevant to the behaviour.

const remote = new VrpcRemote({
    broker: `wss:${window.location.host}/mqtt`,
    domain: 'internal.cybus',
    bestEffort: true,
    username,
    password
})

console.group('Setting up listeners')
remote.on('instanceNew', (added) => console.log('Event fired: instanceNew', added))
remote.on('instanceGone', (gone) => console.log('Event fired: instanceGone', gone))
console.groupEnd()

console.group('Connecting...')
await remote.connect()
console.groupEnd()

console.group('Ending...')
await remote.end()
console.groupEnd()

console.group('Connecting again...')
await remote.connect()
console.groupEnd()

Expected Behavior

Setting up listeners
Connecting...
    Event fired: instanceNew ["docker", "core"]
    Event fired: instanceNew ["testserviceb"]
    Event fired: instanceNew ["servicesCatalog"]
Ending...
Connecting again...
    Event fired: instanceNew ["docker", "core"]
    Event fired: instanceNew ["testserviceb"]
    Event fired: instanceNew ["servicesCatalog"]

Actual

Setting up listeners
Connecting...
    Event fired: instanceNew ["docker", "core"]
    Event fired: instanceNew ["testserviceb"]
    Event fired: instanceNew ["servicesCatalog"]
Ending...
Connecting again...

Documentation:

InstanceGone Event
InstanceNew Event

Error events
Error events seems to only fire on connection issues, due to bad authentication arguments/wrong domain configuration
If I turn off the broker and agents during an active connection, no error event is fired.

Documentation:

Error event

Desktop

  • OS: Ubuntu 20.04
  • Browser: Chrome
  • Version 2.3.2

If you need further context/I missed something, please let me know.

@filipomar filipomar added the bug Something isn't working label Mar 10, 2021
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

1 participant