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

After the computer wakes up from sleeping, my program is stuck without any errors #70

Open
wuminzhe opened this issue Jul 12, 2024 · 7 comments

Comments

@wuminzhe
Copy link

wuminzhe commented Jul 12, 2024

#!/usr/bin/env ruby

require 'async'
require 'async/http/endpoint'
require 'async/websocket/client'

URL = "wss://polkadot-rpc.dwellir.com"

Async do |task|
  endpoint = Async::HTTP::Endpoint.parse(URL)

  Async::WebSocket::Client.connect(endpoint) do |connection|
    connection.write(Protocol::WebSocket::TextMessage.generate({
      "jsonrpc" => "2.0", id: 1, method: "chain_subscribeNewHead", params: []
    }))

    while message = connection.read
      puts message.inspect
    end
  end
end

This is a very simple program that subscribes to new head and prints out it. I found that when my computer is woken up from sleeping, the program will stop working without any errors.

I'm quite new to this gem and async ruby. How do I handle this situation?

@ioquatix
Copy link
Member

Interesting. Do you mind describing a bit more about your computer?

@wuminzhe
Copy link
Author

Interesting. Do you mind describing a bit more about your computer?

I run the program in ubuntu which is running inside windows 11 wsl2.

I'll try it in macos.

@ioquatix
Copy link
Member

It sounds like the connection could be disconnected, but the disconnection is not reported correctly.

@wuminzhe
Copy link
Author

macos has no such problem. my macos version is 14.5

@ioquatix
Copy link
Member

Thanks for your report. I'll check if I can reproduce it on native Linux.

@wuminzhe
Copy link
Author

@ioquatix
Copy link
Member

Sure, I'll take a look.

I'm glad the libraries made it easy for you. It was one of my goals to make it easier to build such things with Ruby.

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

No branches or pull requests

2 participants