Using web_websocket_send in async way?
Is it possible to use web_websocket_send in async way for Polling?
I need async using of websockets for implementing custom heartbeat:
- every 30 seconds clients send a string with custom heartbeat to the server
- the server doesn't respond anything when receives a heartbeat.
I cant use lr_think_time(30) because I have many HTML requests from client which should be parallel with websocket's heartbeats.
Is it possible to use web_reg_async_attributes with web_websocket_send?
web_reg_async_attributes requires an "URL".
But web_websocket_send is based on an connected connection.
I don't think it works.
I understand that you just need a "Timer".
There's a workaround can be tried.
You can call web_reg_async_attributes for another available URL, and make the "RequestCB" trigger the web_websocket_send. So it can work as a "Timer"
//Send your websocket buffer here
"PollIntervalMs=30000", //30 seconds
Another workaround is that Web/HTTP protocol supports not only C but also JS.
Maybe you can find some JS functions to do it.(I mean timer)
LR User Guide says that Async conversations continues until web_stop_async or until the end of iteration.
So If I put Polling in vuser_init it will be stopped at the end of first iteration. Is there any workaround to continue Polling through all iterations until vuser_end execution?
As I remember all the connections will be closed by the end of iteration.
I looks like no workaround to make async connections cross iteration.
BTW, there's pacing time during iterations, so I don't think async timer can work as expected even there's a magic to make it cross iteration.
If you just want to make async cross "vuser_init" and "Action", the answer is "Yes".
Please find "Simulate a new user on each iteration" in RTS and check off it.
Then make the script like
vuser_init <- add web_reg_async_attributes web_url web_websocket_connect and Poll_RequestCB for web_websocket_send here.
Action1 <- you will find Poll_RequestCB can still be triggerred in Action1
Action2 <- you will find Poll_RequestCB can still be triggerred in Action2
vuser_end <-add web_stop_async and web_websocket_close here.
But if you want to make async cross iterations, the answer looks like "No".