Fix exceptions (OnWebSocketReady, requestService)

The crashs have been fixed, however the changes are trivial and may not fix the real problems.