newrelic / video-agent-roku

New Relic Agent for Roku
Apache License 2.0
18 stars 18 forks source link

Network connection and NRTask #17

Closed bchelkowski closed 3 years ago

bchelkowski commented 3 years ago

There is an issue with the loss of the network connection and NRTask. After connection lost and then reconnect, the task stops working even if its state is set to "run".

For now, we can create a walkaround by setting state directly for the NRTask on connection status change:

sub Main(aa as Object)
  ...

  while (true)
    msg = Wait(0, port)
    msgType = Type(msg)

    if (nrProcessMessage(m.nr, msg) = false)
      ...

      if (msgType = "roDeviceInfoEvent")
        if (msg.getInfo() <> Invalid)
          status = msg.getInfo().linkStatus
            if (status = true)
              m.nr.findNode("NRTask").control = "run"
            else if (status = false)
              m.nr.findNode("NRTask").control = "stop"
            end if
        end if
      end if

      ...
    end if
  end while
end sub

However, it would be good to have some agent function that will do this without letting know about this task at all, and maybe which will take care of events that probably will be lost after setting the state to "stop".

asllop commented 3 years ago

Fixed in v1.0.8 (#18)

Looks like when the network disconnects, the wait function inside the NRTask doesn't get notified and it waits forever. I added a timeout (10 seconds), and now is not necessary to manually restart the task.

Please confirm it is working now so I can close the issue.

bchelkowski commented 3 years ago

Thanks! Yes, now it correctly reports events after reconnect.