ConnectionManagerEvent bug?

Added by Casey Foster 786 days ago

With my recent addition of multiple ports, I was working on outputting the information for each connection in a text box as it connected or failed when I ran into this issue.

According to the documentation:
The ConnectionManagerEvent.SELECT_CONNECTION event is followed by either a ConnectionManagerEvent.READY event or a ConnectionManagerEvent.CONNECT_FAILURE event.

I found that the ConnectionManagerEvent.CONNECT_FAILURE event would only occur after the last connection failed, rather than after each one individually as the documentation suggests. For example:
Attempting to connect on port 9100...(ConnectionManagerEvent.SELECT_CONNECTION)
Attempting to connect on port 1080...(ConnectionManagerEvent.SELECT_CONNECTION)
Attempting to connect on port 80...(ConnectionManagerEvent.SELECT_CONNECTION)
Attempt failed. (ConnectionManagerEvent.CONNECT_FAILURE)
Unable to connect. (ReactorEvent.CLOSE)

I was able to get around this by using the ConnectionEvent.CONNECT_FAILURE and applying the event listener to every connection which works perfectly:
Attempting to connect on port 9100... (ConnectionEvent.BEGIN_CONNECT)
Attempt failed. (ConnectionEvent.CONNECT_FAILURE)
Attempting to connect on port 1080... (ConnectionEvent.BEGIN_CONNECT)
Attempt failed. (ConnectionEvent.CONNECT_FAILURE)
Attempting to connect on port 80... (ConnectionEvent.BEGIN_CONNECT)
Attempt failed. (ConnectionEvent.CONNECT_FAILURE)
Unable to connect. (ReactorEvent.CLOSE)

Not sure if this is a bug or working as intended with some slight documentation ambiguity, just a heads up.

Keep up the good work!

-Casey


Replies

RE: ConnectionManagerEvent bug? - Added by colin moock 786 days ago

hi casey,
the docs are correct...if one or more ConnectionManagerEvent.SELECT_CONNECTION events fire, and any of the IConnection objects fail to connect, then a ConnectionManagerEvent.CONNECT_FAILURE will eventually follow. however, i agree that there's some ambiguity, so I've updated the docs to this:

ConnectionManagerEvent.SELECT_CONNECTION
  • An event triggered when the ConnectionManager selects an IConnection
  • object for a connection attempt. Immediately after selecting the connection,
  • the ConnectionManager attempts to connect it. Next, that individual IConnection
  • object dispatches its own ConnectionEvent events indicating whether it was
  • able to connect to Union. If the individual IConnection object cannot
  • connect, the ConnectionManager automatically moves to the next available
  • IConnection object. If any of the IConnection objects in the ConnectionManager's
  • list successfully connects, then ConnectionManager triggers a
  • ConnectionManagerEvent.READY event. If, on the other hand, none of the
  • IConnection objects connects, the ConnectionManager triggers a
  • ConnectionManagerEvent.CONNECT_FAILURE event, indicating that it could
  • not establish a connection via any of the IConnection objects in its list.
  • To add a new IConnection object to the ConnectionManager's connection
  • list, use ConnectionManager's addConnection() method.

thanks for pointing out this issue. please let us know if you notice anything else that's confusing!

colin