Currently experimenting with Angularjs and sockjs, utilizing this helpful resource: https://github.com/bendrucker/angular-sockjs
On page load, I aim to transmit data via sockjs, however, encountering an Error: INVALID_STATE_ERR on the client side when attempting the following:
socket.send("test data");
Presumably, this issue arises due to Sockjs not being fully "ready" yet. When encapsulated within a $timeout
, functionality is achieved with a sufficient delay. A delay of 1000 works, whereas 100 does not.
$timeout(function() {
socket.send("test");
}, 1000);
Clearly a workaround, prompting the question of how to detect when sockjs has fully initialized to proceed with the call efficiently.