Websocket optimization

Only searches database when there are sockets connectes. More
connections to local database.