No async task available! (RuntimeError) #114
Replies: 2 comments 1 reply
-
You will need to run your websocket inside an Async do
Async::WebSocket...
end If you need to, you can run your entire program in an |
Beta Was this translation helpful? Give feedback.
-
I need to use websocket with following functionalities:
I have my async-websocket implementation like this, start method creates a new thread and runs async-websocket related functions inside that forever. def start()
Thread.new {
Async do |task|
endpoint = Async::HTTP::Endpoint.parse(URL)
@ws = Async::WebSocket::Client.open(endpoint).connect(endpoint.authority, endpoint.path)
if !@ws.closed?
send_connection_success_message_to_channel()
end
event_task = task.async do
Thread.new {
loop do
msg = sizedQueue.deq #thread blocks when the queue is empty
@ws.write msg # Exception occurring here
end
}
end
task.async do
while message = @ws.read
process_message(message)
end
rescue EOFError => error
start() #If connections drops this will restart the websocket connection, kind of :on_close
end
end
}
end @ioquatix Can you please help me out finding what's wrong in the above code snippet? |
Beta Was this translation helpful? Give feedback.
-
Any one have any clue why this exception.
Beta Was this translation helpful? Give feedback.
All reactions