Skip to content

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

@wuminzhe

Description

@wuminzhe
#!/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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions