sseclient icon indicating copy to clipboard operation
sseclient copied to clipboard

no data output from events()

Open JinlongWukong opened this issue 5 years ago • 3 comments

sorry to bother you,

I have a question here, if the server side send out event data stream but without (empty new line), then this sseclient will hang there, right? in this case , how to make it work? thanks for your time

JinlongWukong avatar Jan 23 '19 02:01 JinlongWukong

The empty new line is a key part of the SSE spec to separate events being sent by the server. If the server is not sending the empty new line between event then it is not compliant with the specification.

Do you have an example of the server response?

mpetazzoni avatar Jan 23 '19 05:01 mpetazzoni

Thanks for you promt reply. Below is example notification output by using curl command

data:   "ietf-restconf:notification": {
data:     "eventTime": 2019-01-17T05:44:23.073+00:00,
data:     "rmno:network-service": {
data:       "operation": "undeploy",
data:       "status": "init",
data:       "vnf": [
data:         {
data:           "name": "demo_service_mme-7-demo_service_mme",
data:           "esc": {
data:           },
data:           "location": {
data:           }
data:         }
data:       ]
data:     }
data:   }
data: }
data: {
data:   "ietf-restconf:notification": {
data:     "eventTime": 2019-01-17T05:44:23.094+00:00,
data:     "rmno:network-service": {
data:       "operation": "undeploy",
data:       "status": "init",
data:       "vnf": [
data:         {
data:           "name": "demo_service_mme-7-demo_service_mme",
data:           "esc": {
data:           },
data:           "location": {
data:           }
data:         }
data:       ]
data:     }
data:   }
data: }
data: {
data:   "ietf-restconf:notification": {
data:     "eventTime": 2019-01-17T05:45:08.207+00:00,
data:     "rmno:network-service": {
data:       "operation": "undeploy",
data:       "status": "done",
data:       "vnf": [
data:         {
data:           "name": "demo_service_mme-7-demo_service_mme",
data:           "esc": {
data:           },
data:           "location": {
data:           }
data:         }
data:       ]
data:     }
data:   }
data: }

JinlongWukong avatar Jan 23 '19 06:01 JinlongWukong

That is indeed not specification-compliant and would be interpreted as one single large event. Ideally you should change the server to correctly emit an empty new line between each event. Otherwise you'd have to hack something into this library to infer when it is appropriate to dispatch an event (most likely here: https://github.com/mpetazzoni/sseclient/blob/master/sseclient/init.py#L51).

mpetazzoni avatar Jan 24 '19 06:01 mpetazzoni