Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial notification in ngsiv2 is procesed as Bad HTTP notification #2042

Closed
AlvaroVega opened this issue May 20, 2021 · 2 comments
Closed

Comments

@AlvaroVega
Copy link
Member

AlvaroVega commented May 20, 2021

When CB is notifying in ngsiv2 several entities in the same fiware-servicepath (like /)

i.e.:

time=2021-05-20T13:37:25.092Z | lvl=INFO | corr=83099026-b970-11eb-a32f-0242ac110011 | trans=d66f89f2-81b3-450b-8353-f6cc68bafbc5 | srv=smartcity | subsrv=/ | comp=cygnus-ngsi | op=getEvents | msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[324] : [NGSIRestHandler] Received data ({"subscriptionId":"60a661256bbc23164e62d6fb","data":[{"id":"estacion1","type":"WeatherObserved","dateObserved":{"type":"DateTime","value":"2021-02-18T06:00:45.145Z","metadata":{}},"illuminance":{"type":"Number","value":3,"metadata":{}},"solarRadiation":{"type":"Number","value":2,"metadata":{}}},{"id":"WeatherObserved:disp1234bc","type":"WeatherObserved","TimeInstant":{"type":"DateTime","value":"2021-05-20T13:33:07.068Z","metadata":{}},"dateObserved":{"type":"DateTime","value":"2021-05-20T13:32:43.772Z","metadata":{}}}]})
time=2021-05-20T13:37:25.094Z | lvl=WARN | corr=83099026-b970-11eb-a32f-0242ac110011 | trans=d66f89f2-81b3-450b-8353-f6cc68bafbc5 | srv=smartcity | subsrv=/ | comp=cygnus-ngsi | op=getEvents | msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[363] : [NGSIRestHandler] Bad HTTP notification ('fiware-servicepath' header value does not match the number of notified context responses
time=2021-05-20T13:37:25.102Z | lvl=WARN | corr=83099026-b970-11eb-a32f-0242ac110011 | trans=d66f89f2-81b3-450b-8353-f6cc68bafbc5 | srv=smartcity | subsrv=/ | comp=cygnus-ngsi | op=doPost | msg=org.apache.flume.source.http.HTTPSource$FlumeHTTPServlet[237] : Received bad request from client.
org.apache.flume.source.http.HTTPBadRequestException: 'fiware-servicepath' header value does not match the number of notified context responses
at com.telefonica.iot.cygnus.handlers.NGSIRestHandler.getEvents(NGSIRestHandler.java:366)
at org.apache.flume.source.http.HTTPSource$FlumeHTTPServlet.doPost(HTTPSource.java:235)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)

done in

if (servicePaths.length != ncr.getContextResponses().size()) {
serviceMetrics.add(service, servicePath, 1, request.getContentLength(), 0, 1, 0, 0, 0, 0, 0);
LOGGER.warn("[NGSIRestHandler] Bad HTTP notification ('"
+ CommonConstants.HEADER_FIWARE_SERVICE_PATH
+ "' header value does not match the number of notified context responses");
throw new HTTPBadRequestException(
"'" + CommonConstants.HEADER_FIWARE_SERVICE_PATH
+ "' header value does not match the number of notified context responses");
} // if

According with NGSv2 spec:
https://fiware-orion.readthedocs.io/en/master/user/initial_notification/index.html

As happens with non-initial notification, the Fiware-ServicePath header is included in initial notification. However, note that an initial notification potentially includes several (more than one) entities, which may belong to different service paths. Thus, a list of comma separated values is used (the first element in the Fiware-ServicePath list corresponding to the first entity, etc.). 

IMHO which may belong to different service paths or the same service path

@AlvaroVega AlvaroVega changed the title initial subscription in ngsiv2 is procesed as Bad HTTP notification initial notification in ngsiv2 is procesed as Bad HTTP notification May 20, 2021
@AlvaroVega
Copy link
Member Author

related
telefonicaid/fiware-orion#3857

@fgalan
Copy link
Member

fgalan commented May 21, 2021

Fixed by PR #2043

This issue has a continuation in #2044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants