How to close connection in sse.js
Closed this issue · 1 comments
I have created connection with sse.js
let url = "https://XXXXXXXX/stream"; let requestJson = { "id" : "123456" }; var source = new SSE(url, { headers: { 'Content-Type': 'application/json', 'Authorization': 'wefergre735rb23v23j23vj3vh43v43', }, payload: JSON.stringify(requestJson), method: 'POST' });
And Get Stream data with below code
source.addEventListener('message', function(e) { payload = JSON.parse(e.data); }); source.stream();
And i want to close connection with below code but it's not working
source.close();
Thanks
What is not working exactly? Do you mean that the connection remains open, and your message
event listener is still being called when data is received?
Can you step-by-step debug through the call to source.close()
and confirm that the XHR request gets cancelled as expected?