webSocket connection to 'ws://---/sockjs-node' failed

I get token with /rest/api_key in moqui and set header like
headers: {
‘Authorization’ : ‘Basic ’ + window.btoa(username+’:’+password),
“Content-Type” : “application/json”
}
for first time I logged in every thing is OK but when I refresh the page , the below error happens :
WebSocket connection to ‘ws://—/sockjs-node’ failed:
and token deleted , and user logged out ,
my problem is logging out the user and I guess this happen because of this error
am I right ?