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

415 error while trying to execute a rule manually #328

Open
candiesdoodle opened this issue Feb 9, 2021 · 6 comments
Open

415 error while trying to execute a rule manually #328

candiesdoodle opened this issue Feb 9, 2021 · 6 comments

Comments

@candiesdoodle
Copy link

candiesdoodle commented Feb 9, 2021

On myopenhab.org
While trying to trigger a rule manually from UI by clicking the play button, there is an error "Error while running the rule: Ok"

In the openhab logs there is a 415 error
I have tried with other rules too as call be seen in the screenshots
When trying to do the same from local network, the rule is executed as expected.
I had posted here in the community but didn't get a response. I have also upgraded to the latest snapshot but this still remains

2021-02-09 07:58:47.357 [WARN ] [s.impl.WebApplicationExceptionMapper] - javax.ws.rs.ClientErrorException: HTTP 415 Unsupported Media Type
	at org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:117)
	at org.apache.cxf.jaxrs.utils.ExceptionUtils.toHttpException(ExceptionUtils.java:168)
	at org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:514)
	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:181)
	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544)
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307)
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:494)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918)
	at java.base/java.lang.Thread.run(Thread.java:834)

Expected behavior

The rule should execute

Steps to reproduce

  1. Goto myopenhab.org and login
  2. Try to execute a rule manually by clicking the play button
@candiesdoodle
Copy link
Author

Hello, any feedback on this
Thanks

@iwilliamson
Copy link

I too have this problem but seem to have narrowed it down a bit.

  1. It happens when I have an overview cell that triggers a rule on click
  2. It DOESN'T happen when I'm directly connected to my OpenHAB instance
  3. It only happens when I'm connected through a cloud instance (either myopenhab.org or my personal cloud server)

The error itself seems to be generated because a REST POST request is made, without setting the content-type in the header to application/json.

As to WHERE in the code that's happening, I have no idea yet.

@iwilliamson
Copy link

I fixed this for myself in my personal cloud instance (though I think it's a bug in the OpenHab Core). The trouble is, when you're running rules directly, there is no data for the REST API call. I suspect that, because there is no data, the "content-type" setting for the request never gets set.

I added a simple change in routes/index.js, Routes.prototype.proxyRouteOpenhab() to add a "content-type" header entry if there wasn't one, just before the call where the request is forwarded:

    if( requestHeaders['content-type'] === undefined )
    {
        requestHeaders['content-type'] = 'text/plain';
    }

    // Send a message with request to openhab agent module
    this.io.sockets.in(req.openhab.uuid).emit('request', {
        id: requestId,
        method: req.method,
        headers: requestHeaders,
        path: requestPath,
        query: req.query,
        body: req.rawBody
    });

@iwilliamson
Copy link

Alright, just adding content-type of plain/text is not the answer...It seems to have side effects that cause the web page not to load...

@iwilliamson
Copy link

I've had some time to do a little more research and SEEM to have it working now. I think the trouble is that the content-length is set (to zero) but no content-type gets set. So the fix that seems to work without any side effects is:

    if( requestHeaders['content-length'] === '0' )
    {
        requestHeaders['content-type'] = 'text/plain';
    }

    // Send a message with request to openhab agent module
    this.io.sockets.in(req.openhab.uuid).emit('request', {
        id: requestId,
        method: req.method,
        headers: requestHeaders,
        path: requestPath,
        query: req.query,
        body: req.rawBody
    });

I've been using it for a while now without any side effects except my rule running properly.

Could someone else please try it out and see if that's the fix?

digitaldan added a commit to digitaldan/openhab-addons that referenced this issue Apr 27, 2021
This fixes a number of open issues due to the fact that we were only accepting a limited number of http method types.  The effect of this was some functionality like DELETE or HEAD requests would just not work when using the cloud service, which madee our UI look broken in different ways,  also it poluted the users log with a lot of messages.

openhab/openhab-core#2312
openhab/openhab-cloud#328

Signed-off-by: Dan Cunningham <[email protected]>
cweitkamp pushed a commit to openhab/openhab-addons that referenced this issue Apr 28, 2021
* Accept all Jetty supported http method types
This fixes a number of open issues due to the fact that we were only accepting a limited number of http method types.  The effect of this was some functionality like DELETE or HEAD requests would just not work when using the cloud service, which madee our UI look broken in different ways,  also it poluted the users log with a lot of messages.

Fixes openhab/openhab-core#2312
Fixes openhab/openhab-cloud#328

Signed-off-by: Dan Cunningham <[email protected]>
@cweitkamp
Copy link
Contributor

openhab/openhab-addons#10600 has been merged.

themillhousegroup pushed a commit to themillhousegroup/openhab2-addons that referenced this issue May 10, 2021
…10600)

* Accept all Jetty supported http method types
This fixes a number of open issues due to the fact that we were only accepting a limited number of http method types.  The effect of this was some functionality like DELETE or HEAD requests would just not work when using the cloud service, which madee our UI look broken in different ways,  also it poluted the users log with a lot of messages.

Fixes openhab/openhab-core#2312
Fixes openhab/openhab-cloud#328

Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: John Marshall <[email protected]>
computergeek1507 pushed a commit to computergeek1507/openhab-addons that referenced this issue Jul 13, 2021
…10600)

* Accept all Jetty supported http method types
This fixes a number of open issues due to the fact that we were only accepting a limited number of http method types.  The effect of this was some functionality like DELETE or HEAD requests would just not work when using the cloud service, which madee our UI look broken in different ways,  also it poluted the users log with a lot of messages.

Fixes openhab/openhab-core#2312
Fixes openhab/openhab-cloud#328

Signed-off-by: Dan Cunningham <[email protected]>
frederictobiasc pushed a commit to frederictobiasc/openhab-addons that referenced this issue Oct 26, 2021
…10600)

* Accept all Jetty supported http method types
This fixes a number of open issues due to the fact that we were only accepting a limited number of http method types.  The effect of this was some functionality like DELETE or HEAD requests would just not work when using the cloud service, which madee our UI look broken in different ways,  also it poluted the users log with a lot of messages.

Fixes openhab/openhab-core#2312
Fixes openhab/openhab-cloud#328

Signed-off-by: Dan Cunningham <[email protected]>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this issue Nov 7, 2021
…10600)

* Accept all Jetty supported http method types
This fixes a number of open issues due to the fact that we were only accepting a limited number of http method types.  The effect of this was some functionality like DELETE or HEAD requests would just not work when using the cloud service, which madee our UI look broken in different ways,  also it poluted the users log with a lot of messages.

Fixes openhab/openhab-core#2312
Fixes openhab/openhab-cloud#328

Signed-off-by: Dan Cunningham <[email protected]>
marcfischerboschio pushed a commit to marcfischerboschio/openHABaddon that referenced this issue Apr 20, 2022
* Accept all Jetty supported http method types
This fixes a number of open issues due to the fact that we were only accepting a limited number of http method types.  The effect of this was some functionality like DELETE or HEAD requests would just not work when using the cloud service, which madee our UI look broken in different ways,  also it poluted the users log with a lot of messages.

Fixes openhab/openhab-core#2312
Fixes openhab/openhab-cloud#328

Signed-off-by: Dan Cunningham <[email protected]>
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

3 participants