Skip to content

events without subprotocol might be causing unexpected behaviour #1281

@VigneshVSV

Description

@VigneshVSV

I use events primarily with HTTP SSE.

When I generate the TD without the subprotocol option within the event affordance, the node-wot client subscribes to the event multiple times.

The event afffordance (faulty) schema is as follows:

intensity_measurement_event": {
      "forms": [
        {
          "href": "https://LAPTOP-F60CU35D:8083/spectrometer/ocean-optics/USB2000-plus/intensity/measurement-event",
          "op": "subscribeevent",
          "htv:methodName": "GET",
          "contentType": "text/event-stream"
        }
      ]
    }

The validator does not complain. When the client tries to subscribe to the event:

 spectrometer.subscribeEvent("intensity_measurement_event", async(data : InteractionOutput) => {
 const value = await data.value()
 console.log("event", value, data)            
 }).then((subscription : any) => {
     intensityMeasurementEvent = subscription 
     console.debug("subscribed to intensity measurement event")
 })

This somehow leads to 6 event subscriptions to the server side. I get the following output:

App.svelte:37 consumed thing description from spectrometer
App.svelte:43 updating state
App.svelte:59 action with value InteractionOutput {form: {}, schema: undefined, dataUsed: false}
App.svelte:60 action with value undefined
MainView.svelte:45 subscribed to intensity measurement event
MainView.svelte:42 event undefined InteractionOutput {form: {}, schema: undefined, dataUsed: false}
MainView.svelte:42 event undefined InteractionOutput {form: {}, schema: undefined, dataUsed: false}
MainView.svelte:42 event undefined InteractionOutput {form: {}, schema: undefined, dataUsed: false}
MainView.svelte:42 event undefined InteractionOutput {form: {}, schema: undefined, dataUsed: false}
MainView.svelte:42 event undefined InteractionOutput {form: {}, schema: undefined, dataUsed: false}
App.svelte:77 rescheduling property polling function

From server side:

count 42
DEBUG    - 2024-05-02T20:29:03:171 - spectrometer/ocean-optics/USB2000-plus - starting measurement count 43
DEBUG    - 2024-05-02T20:29:03:172 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:03:173 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:03:174 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:03:175 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:03:175 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:03:176 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:04:182 - spectrometer/ocean-optics/USB2000-plus - measurement taken at 02.05.2024 20:29:04.182 - measurement count 43
DEBUG    - 2024-05-02T20:29:04:184 - spectrometer/ocean-optics/USB2000-plus - starting measurement count 44
DEBUG    - 2024-05-02T20:29:04:185 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:04:186 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:04:187 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:04:188 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:04:188 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:04:189 - HTTPServer|0.0.0.0:8083 - new data sent - intensity-measurement-event
DEBUG    - 2024-05-02T20:29:05:196 - spectrometer/ocean-optics/USB2000-plus - measurement taken at 02.05.2024 20:29:05.196 - measurement count 44

The event is being sent, but there are 6 of them (each line claiming "new data sent" is a single event of same type). Also, I am not able to invoke further actions.

When adding the subprotocol field, the issue is solved. However, due to absence of schema the event value is undefined.
(#1280)

The TD document also says subprotocol is optional, may I know what is the default value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    binding-httpIssues related to http protocol binding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions