Skip to content

Fix intermittent issues on CI#36

Merged
route merged 1 commit intomasterfrom
travis-ci-2
Jan 24, 2019
Merged

Fix intermittent issues on CI#36
route merged 1 commit intomasterfrom
travis-ci-2

Conversation

@route
Copy link
Member

@route route commented Jan 23, 2019

No description provided.

@route
Copy link
Member Author

route commented Jan 23, 2019

@iainbeeston Tests look much better now, the real cause was https://github.com/machinio/cuprite/pull/36/files#diff-9948fab217d02bb27cd531aa7af30938R40

@jcoglan I see that in faye/websocket-driver-ruby#46 people had similar issues. It looks like when you send message way too faster than on_open is called websocket connection remains indefinitely in :connecting state. I didn't find any better solution than put sleep 0.01
Don't think it's the best. What can we do?

@thread.kill
end

def send(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey is it a good idea to define the method as send? Won't that override Object#send?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, I was just copy-pasting from websocket example, I'll put it back

end

def close
@driver.close
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Socket#close also call @thread.join, just like Client#close above? When I was reading the examples for websocket-driver I noticed that they do that in their socket class but curprite does not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

websocket-driver has two versions of close. One is event-driven https://github.com/faye/websocket-driver-ruby/blob/master/examples/tcp_client.rb#L25 and another one is plain close like the one we use https://github.com/faye/websocket-driver-ruby/blob/master/examples/tcp_client.rb#L42. I think it's pretty much close to what they have in example. Though @thread.join doesn't help as thread can be blocked on IO and they have to use kill as we do.

@iainbeeston
Copy link
Contributor

Wow travis looks far better on this branch! 😀

@driver.text(json)
@logger&.puts("\n\n>>> #{json}")
def on_open(_event)
sleep 0.01 # https://github.com/faye/websocket-driver-ruby/issues/46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just read that github issue now - would it be possible to loop/sleep here until the state of the socket is not "connecting"? I'm not sure if that is possible, but if it is it might be more reliable, and also it would be easier to understand why the code is sleeping

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that looping in here will hang the only thread we have and make it even worse but I haven't tried it so I can be wrong. All callbacks get executed in @thread and if we don't return from on_open we may never change state. I don't fully understand how to handle it properly so asked @jcoglan for a perfect solution but he didn't have time to answer yet.

@route
Copy link
Member Author

route commented Jan 24, 2019

@iainbeeston oook looks good enough to me to merge it and then deal with refactoring and stuff

@route route merged commit 2da175a into master Jan 24, 2019
@route route deleted the travis-ci-2 branch January 24, 2019 16:47
saikumar-everest pushed a commit to saikumar-everest/cuprite that referenced this pull request Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants