Wicket WebSockets problem with servlet context

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Wicket WebSockets problem with servlet context

Tom Götz
Hi there,

I have the following scenario:

1.
a Spring-Boot Wicket application with Tomcat running on Port 8080 that uses Wicket WebSockets impl running in the servlet root context

2.
a ngnix server that proxies /MyLocation to the mentioned Wicket app

As there is no servlet context involved, the generated WebSockets endpoint url is generated by Wicket as: ws://mydomain.com/wicket/websocket?pageId=1&wicket-ajax-baseurl=...

I saw that this url is generated in BaseWebSocketBehavior#renderHead by asking the request for the context path:

String contextPath = component.getRequest().getContextPath();
variables.put("contextPath", contextPath);

As I don’t have a contextPath, this fails:

WebSocket connection to 'ws://mydomaon.com/wicket/websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during WebSocket handshake: Unexpected response code: 404

Does the Wicket WebSocket API provide a way to handle such a scenario? Currently, I’m studying the code but any pointer would be helpful …

Cheers,
   Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Tom Götz
Maybe answering my own question, but this here could help … I’ll give it a try:
http://stackoverflow.com/questions/32287103/how-to-use-nginx-as-a-proxy-for-wicket-application-using-websockets

Cheers,
   Tom


> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
>
> Hi there,
>
> I have the following scenario:
>
> 1.
> a Spring-Boot Wicket application with Tomcat running on Port 8080 that uses Wicket WebSockets impl running in the servlet root context
>
> 2.
> a ngnix server that proxies /MyLocation to the mentioned Wicket app
>
> As there is no servlet context involved, the generated WebSockets endpoint url is generated by Wicket as: ws://mydomain.com/wicket/websocket?pageId=1&wicket-ajax-baseurl=...
>
> I saw that this url is generated in BaseWebSocketBehavior#renderHead by asking the request for the context path:
>
> String contextPath = component.getRequest().getContextPath();
> variables.put("contextPath", contextPath);
>
> As I don’t have a contextPath, this fails:
>
> WebSocket connection to 'ws://mydomaon.com/wicket/websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during WebSocket handshake: Unexpected response code: 404
>
> Does the Wicket WebSocket API provide a way to handle such a scenario? Currently, I’m studying the code but any pointer would be helpful …
>
> Cheers,
>   Tom
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Tom Götz
Hm, no solution yet … anyone got a working example or some hint maybe?

   Tom


> On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
>
> Maybe answering my own question, but this here could help … I’ll give it a try:
> http://stackoverflow.com/questions/32287103/how-to-use-nginx-as-a-proxy-for-wicket-application-using-websockets
>
> Cheers,
>   Tom
>
>
>> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
>>
>> Hi there,
>>
>> I have the following scenario:
>>
>> 1.
>> a Spring-Boot Wicket application with Tomcat running on Port 8080 that uses Wicket WebSockets impl running in the servlet root context
>>
>> 2.
>> a ngnix server that proxies /MyLocation to the mentioned Wicket app
>>
>> As there is no servlet context involved, the generated WebSockets endpoint url is generated by Wicket as: ws://mydomain.com/wicket/websocket?pageId=1&wicket-ajax-baseurl=...
>>
>> I saw that this url is generated in BaseWebSocketBehavior#renderHead by asking the request for the context path:
>>
>> String contextPath = component.getRequest().getContextPath();
>> variables.put("contextPath", contextPath);
>>
>> As I don’t have a contextPath, this fails:
>>
>> WebSocket connection to 'ws://mydomaon.com/wicket/websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during WebSocket handshake: Unexpected response code: 404
>>
>> Does the Wicket WebSocket API provide a way to handle such a scenario? Currently, I’m studying the code but any pointer would be helpful …
>>
>> Cheers,
>>  Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Martin Grigorov-4
Hi Tom,

The problem really is in wicket-websocket-jquery.js.
It does: url = protocol + '//' + document.location.host + WWS.contextPath +
WWS.filterPrefix + '/wicket/websocket';

A workaround for you is to add url rewrite rule to Nginx to forward it to
Tomcat.

Please file an issue at JIRA and I'll see how this could be improved.


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Oct 5, 2016 at 4:31 PM, Tom Götz <[hidden email]> wrote:

> Hm, no solution yet … anyone got a working example or some hint maybe?
>
>    Tom
>
>
> > On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
> >
> > Maybe answering my own question, but this here could help … I’ll give it
> a try:
> > http://stackoverflow.com/questions/32287103/how-to-use-
> nginx-as-a-proxy-for-wicket-application-using-websockets
> >
> > Cheers,
> >   Tom
> >
> >
> >> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
> >>
> >> Hi there,
> >>
> >> I have the following scenario:
> >>
> >> 1.
> >> a Spring-Boot Wicket application with Tomcat running on Port 8080 that
> uses Wicket WebSockets impl running in the servlet root context
> >>
> >> 2.
> >> a ngnix server that proxies /MyLocation to the mentioned Wicket app
> >>
> >> As there is no servlet context involved, the generated WebSockets
> endpoint url is generated by Wicket as: ws://mydomain.com/wicket/
> websocket?pageId=1&wicket-ajax-baseurl=...
> >>
> >> I saw that this url is generated in BaseWebSocketBehavior#renderHead
> by asking the request for the context path:
> >>
> >> String contextPath = component.getRequest().getContextPath();
> >> variables.put("contextPath", contextPath);
> >>
> >> As I don’t have a contextPath, this fails:
> >>
> >> WebSocket connection to 'ws://mydomaon.com/wicket/
> websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during
> WebSocket handshake: Unexpected response code: 404
> >>
> >> Does the Wicket WebSocket API provide a way to handle such a scenario?
> Currently, I’m studying the code but any pointer would be helpful …
> >>
> >> Cheers,
> >>  Tom
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Tom Götz
Hi Martin,

what exactly is the problem in wicket-websocket-jquery.js? As I said, I have no contextPath, so I wouldn’t expect Wicket/wicket-websocket-jquery.js to know under which context the app is running. Shouldn’t I provide the context/mountPath somehow to the websocket initialization process?!

   Tom

> On 05.10.2016, at 16:47, Martin Grigorov <[hidden email]> wrote:
>
> Hi Tom,
>
> The problem really is in wicket-websocket-jquery.js.
> It does: url = protocol + '//' + document.location.host + WWS.contextPath +
> WWS.filterPrefix + '/wicket/websocket';
>
> A workaround for you is to add url rewrite rule to Nginx to forward it to
> Tomcat.
>
> Please file an issue at JIRA and I'll see how this could be improved.
>
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Oct 5, 2016 at 4:31 PM, Tom Götz <[hidden email]> wrote:
>
>> Hm, no solution yet … anyone got a working example or some hint maybe?
>>
>>   Tom
>>
>>
>>> On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
>>>
>>> Maybe answering my own question, but this here could help … I’ll give it
>> a try:
>>> http://stackoverflow.com/questions/32287103/how-to-use-
>> nginx-as-a-proxy-for-wicket-application-using-websockets
>>>
>>> Cheers,
>>>  Tom
>>>
>>>
>>>> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
>>>>
>>>> Hi there,
>>>>
>>>> I have the following scenario:
>>>>
>>>> 1.
>>>> a Spring-Boot Wicket application with Tomcat running on Port 8080 that
>> uses Wicket WebSockets impl running in the servlet root context
>>>>
>>>> 2.
>>>> a ngnix server that proxies /MyLocation to the mentioned Wicket app
>>>>
>>>> As there is no servlet context involved, the generated WebSockets
>> endpoint url is generated by Wicket as: ws://mydomain.com/wicket/
>> websocket?pageId=1&wicket-ajax-baseurl=...
>>>>
>>>> I saw that this url is generated in BaseWebSocketBehavior#renderHead
>> by asking the request for the context path:
>>>>
>>>> String contextPath = component.getRequest().getContextPath();
>>>> variables.put("contextPath", contextPath);
>>>>
>>>> As I don’t have a contextPath, this fails:
>>>>
>>>> WebSocket connection to 'ws://mydomaon.com/wicket/
>> websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during
>> WebSocket handshake: Unexpected response code: 404
>>>>
>>>> Does the Wicket WebSocket API provide a way to handle such a scenario?
>> Currently, I’m studying the code but any pointer would be helpful …
>>>>
>>>> Cheers,
>>>> Tom
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Martin Grigorov-4
The problem is that Nginx is configured to forward requests to /MyLocation
to Tomcat, and the application has no idea about this.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Oct 5, 2016 at 5:25 PM, Tom Götz <[hidden email]> wrote:

> Hi Martin,
>
> what exactly is the problem in wicket-websocket-jquery.js? As I said, I
> have no contextPath, so I wouldn’t expect Wicket/wicket-websocket-jquery.js
> to know under which context the app is running. Shouldn’t I provide the
> context/mountPath somehow to the websocket initialization process?!
>
>    Tom
>
> > On 05.10.2016, at 16:47, Martin Grigorov <[hidden email]> wrote:
> >
> > Hi Tom,
> >
> > The problem really is in wicket-websocket-jquery.js.
> > It does: url = protocol + '//' + document.location.host +
> WWS.contextPath +
> > WWS.filterPrefix + '/wicket/websocket';
> >
> > A workaround for you is to add url rewrite rule to Nginx to forward it to
> > Tomcat.
> >
> > Please file an issue at JIRA and I'll see how this could be improved.
> >
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> > On Wed, Oct 5, 2016 at 4:31 PM, Tom Götz <[hidden email]> wrote:
> >
> >> Hm, no solution yet … anyone got a working example or some hint maybe?
> >>
> >>   Tom
> >>
> >>
> >>> On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
> >>>
> >>> Maybe answering my own question, but this here could help … I’ll give
> it
> >> a try:
> >>> http://stackoverflow.com/questions/32287103/how-to-use-
> >> nginx-as-a-proxy-for-wicket-application-using-websockets
> >>>
> >>> Cheers,
> >>>  Tom
> >>>
> >>>
> >>>> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
> >>>>
> >>>> Hi there,
> >>>>
> >>>> I have the following scenario:
> >>>>
> >>>> 1.
> >>>> a Spring-Boot Wicket application with Tomcat running on Port 8080 that
> >> uses Wicket WebSockets impl running in the servlet root context
> >>>>
> >>>> 2.
> >>>> a ngnix server that proxies /MyLocation to the mentioned Wicket app
> >>>>
> >>>> As there is no servlet context involved, the generated WebSockets
> >> endpoint url is generated by Wicket as: ws://mydomain.com/wicket/
> >> websocket?pageId=1&wicket-ajax-baseurl=...
> >>>>
> >>>> I saw that this url is generated in BaseWebSocketBehavior#renderHead
> >> by asking the request for the context path:
> >>>>
> >>>> String contextPath = component.getRequest().getContextPath();
> >>>> variables.put("contextPath", contextPath);
> >>>>
> >>>> As I don’t have a contextPath, this fails:
> >>>>
> >>>> WebSocket connection to 'ws://mydomaon.com/wicket/
> >> websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during
> >> WebSocket handshake: Unexpected response code: 404
> >>>>
> >>>> Does the Wicket WebSocket API provide a way to handle such a scenario?
> >> Currently, I’m studying the code but any pointer would be helpful …
> >>>>
> >>>> Cheers,
> >>>> Tom
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Tom Götz
I created a JIRA for this: https://issues.apache.org/jira/browse/WICKET-6254

   Tom


> On 05.10.2016, at 17:31, Martin Grigorov <[hidden email]> wrote:
>
> The problem is that Nginx is configured to forward requests to /MyLocation
> to Tomcat, and the application has no idea about this.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Oct 5, 2016 at 5:25 PM, Tom Götz <[hidden email]> wrote:
>
>> Hi Martin,
>>
>> what exactly is the problem in wicket-websocket-jquery.js? As I said, I
>> have no contextPath, so I wouldn’t expect Wicket/wicket-websocket-jquery.js
>> to know under which context the app is running. Shouldn’t I provide the
>> context/mountPath somehow to the websocket initialization process?!
>>
>>   Tom
>>
>>> On 05.10.2016, at 16:47, Martin Grigorov <[hidden email]> wrote:
>>>
>>> Hi Tom,
>>>
>>> The problem really is in wicket-websocket-jquery.js.
>>> It does: url = protocol + '//' + document.location.host +
>> WWS.contextPath +
>>> WWS.filterPrefix + '/wicket/websocket';
>>>
>>> A workaround for you is to add url rewrite rule to Nginx to forward it to
>>> Tomcat.
>>>
>>> Please file an issue at JIRA and I'll see how this could be improved.
>>>
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>> https://twitter.com/mtgrigorov
>>>
>>> On Wed, Oct 5, 2016 at 4:31 PM, Tom Götz <[hidden email]> wrote:
>>>
>>>> Hm, no solution yet … anyone got a working example or some hint maybe?
>>>>
>>>>  Tom
>>>>
>>>>
>>>>> On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
>>>>>
>>>>> Maybe answering my own question, but this here could help … I’ll give
>> it
>>>> a try:
>>>>> http://stackoverflow.com/questions/32287103/how-to-use-
>>>> nginx-as-a-proxy-for-wicket-application-using-websockets
>>>>>
>>>>> Cheers,
>>>>> Tom
>>>>>
>>>>>
>>>>>> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
>>>>>>
>>>>>> Hi there,
>>>>>>
>>>>>> I have the following scenario:
>>>>>>
>>>>>> 1.
>>>>>> a Spring-Boot Wicket application with Tomcat running on Port 8080 that
>>>> uses Wicket WebSockets impl running in the servlet root context
>>>>>>
>>>>>> 2.
>>>>>> a ngnix server that proxies /MyLocation to the mentioned Wicket app
>>>>>>
>>>>>> As there is no servlet context involved, the generated WebSockets
>>>> endpoint url is generated by Wicket as: ws://mydomain.com/wicket/
>>>> websocket?pageId=1&wicket-ajax-baseurl=...
>>>>>>
>>>>>> I saw that this url is generated in BaseWebSocketBehavior#renderHead
>>>> by asking the request for the context path:
>>>>>>
>>>>>> String contextPath = component.getRequest().getContextPath();
>>>>>> variables.put("contextPath", contextPath);
>>>>>>
>>>>>> As I don’t have a contextPath, this fails:
>>>>>>
>>>>>> WebSocket connection to 'ws://mydomaon.com/wicket/
>>>> websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during
>>>> WebSocket handshake: Unexpected response code: 404
>>>>>>
>>>>>> Does the Wicket WebSocket API provide a way to handle such a scenario?
>>>> Currently, I’m studying the code but any pointer would be helpful …
>>>>>>
>>>>>> Cheers,
>>>>>> Tom
>>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Tom Götz
BTW, I already tried the following workaround without success:

I did override WebSocketBehavior#renderHead and included a „patched“ JS init script that contained the contextPath that ngnix is forwarding to, so the generated JS looked like this:

if (typeof(Wicket.WebSocket.appName) === "undefined") {
  jQuery.extend(Wicket.WebSocket, { pageId: 1, resourceName: '',
    baseUrl: ‚MyHomePage?1', contextPath: ‚/MyLocation', appName: ‚myApp',
    filterPrefix: '' });
  Wicket.WebSocket.createDefaultConnection();
}

But still I got an 404 for the ws endpoint …

   Tom


> On 05.10.2016, at 17:35, Tom Götz <[hidden email]> wrote:
>
> I created a JIRA for this: https://issues.apache.org/jira/browse/WICKET-6254
>
>   Tom
>
>
>> On 05.10.2016, at 17:31, Martin Grigorov <[hidden email]> wrote:
>>
>> The problem is that Nginx is configured to forward requests to /MyLocation
>> to Tomcat, and the application has no idea about this.
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>>
>> On Wed, Oct 5, 2016 at 5:25 PM, Tom Götz <[hidden email]> wrote:
>>
>>> Hi Martin,
>>>
>>> what exactly is the problem in wicket-websocket-jquery.js? As I said, I
>>> have no contextPath, so I wouldn’t expect Wicket/wicket-websocket-jquery.js
>>> to know under which context the app is running. Shouldn’t I provide the
>>> context/mountPath somehow to the websocket initialization process?!
>>>
>>>  Tom
>>>
>>>> On 05.10.2016, at 16:47, Martin Grigorov <[hidden email]> wrote:
>>>>
>>>> Hi Tom,
>>>>
>>>> The problem really is in wicket-websocket-jquery.js.
>>>> It does: url = protocol + '//' + document.location.host +
>>> WWS.contextPath +
>>>> WWS.filterPrefix + '/wicket/websocket';
>>>>
>>>> A workaround for you is to add url rewrite rule to Nginx to forward it to
>>>> Tomcat.
>>>>
>>>> Please file an issue at JIRA and I'll see how this could be improved.
>>>>
>>>>
>>>> Martin Grigorov
>>>> Wicket Training and Consulting
>>>> https://twitter.com/mtgrigorov
>>>>
>>>> On Wed, Oct 5, 2016 at 4:31 PM, Tom Götz <[hidden email]> wrote:
>>>>
>>>>> Hm, no solution yet … anyone got a working example or some hint maybe?
>>>>>
>>>>> Tom
>>>>>
>>>>>
>>>>>> On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
>>>>>>
>>>>>> Maybe answering my own question, but this here could help … I’ll give
>>> it
>>>>> a try:
>>>>>> http://stackoverflow.com/questions/32287103/how-to-use-
>>>>> nginx-as-a-proxy-for-wicket-application-using-websockets
>>>>>>
>>>>>> Cheers,
>>>>>> Tom
>>>>>>
>>>>>>
>>>>>>> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
>>>>>>>
>>>>>>> Hi there,
>>>>>>>
>>>>>>> I have the following scenario:
>>>>>>>
>>>>>>> 1.
>>>>>>> a Spring-Boot Wicket application with Tomcat running on Port 8080 that
>>>>> uses Wicket WebSockets impl running in the servlet root context
>>>>>>>
>>>>>>> 2.
>>>>>>> a ngnix server that proxies /MyLocation to the mentioned Wicket app
>>>>>>>
>>>>>>> As there is no servlet context involved, the generated WebSockets
>>>>> endpoint url is generated by Wicket as: ws://mydomain.com/wicket/
>>>>> websocket?pageId=1&wicket-ajax-baseurl=...
>>>>>>>
>>>>>>> I saw that this url is generated in BaseWebSocketBehavior#renderHead
>>>>> by asking the request for the context path:
>>>>>>>
>>>>>>> String contextPath = component.getRequest().getContextPath();
>>>>>>> variables.put("contextPath", contextPath);
>>>>>>>
>>>>>>> As I don’t have a contextPath, this fails:
>>>>>>>
>>>>>>> WebSocket connection to 'ws://mydomaon.com/wicket/
>>>>> websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during
>>>>> WebSocket handshake: Unexpected response code: 404
>>>>>>>
>>>>>>> Does the Wicket WebSocket API provide a way to handle such a scenario?
>>>>> Currently, I’m studying the code but any pointer would be helpful …
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Tom
>>>>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Tom Götz
… so what I was trying to say (I’m not yet too deep into the websockets tech):

isn’t it —in the described case— also necessary to configure the mount point of the WS endpoint?

   Tom



> On 05.10.2016, at 17:42, Tom Götz <[hidden email]> wrote:
>
> BTW, I already tried the following workaround without success:
>
> I did override WebSocketBehavior#renderHead and included a „patched“ JS init script that contained the contextPath that ngnix is forwarding to, so the generated JS looked like this:
>
> if (typeof(Wicket.WebSocket.appName) === "undefined") {
>  jQuery.extend(Wicket.WebSocket, { pageId: 1, resourceName: '',
>    baseUrl: ‚MyHomePage?1', contextPath: ‚/MyLocation', appName: ‚myApp',
>    filterPrefix: '' });
>  Wicket.WebSocket.createDefaultConnection();
> }
>
> But still I got an 404 for the ws endpoint …
>
>   Tom
>
>
>> On 05.10.2016, at 17:35, Tom Götz <[hidden email]> wrote:
>>
>> I created a JIRA for this: https://issues.apache.org/jira/browse/WICKET-6254
>>
>>  Tom
>>
>>
>>> On 05.10.2016, at 17:31, Martin Grigorov <[hidden email]> wrote:
>>>
>>> The problem is that Nginx is configured to forward requests to /MyLocation
>>> to Tomcat, and the application has no idea about this.
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>> https://twitter.com/mtgrigorov
>>>
>>> On Wed, Oct 5, 2016 at 5:25 PM, Tom Götz <[hidden email]> wrote:
>>>
>>>> Hi Martin,
>>>>
>>>> what exactly is the problem in wicket-websocket-jquery.js? As I said, I
>>>> have no contextPath, so I wouldn’t expect Wicket/wicket-websocket-jquery.js
>>>> to know under which context the app is running. Shouldn’t I provide the
>>>> context/mountPath somehow to the websocket initialization process?!
>>>>
>>>> Tom
>>>>
>>>>> On 05.10.2016, at 16:47, Martin Grigorov <[hidden email]> wrote:
>>>>>
>>>>> Hi Tom,
>>>>>
>>>>> The problem really is in wicket-websocket-jquery.js.
>>>>> It does: url = protocol + '//' + document.location.host +
>>>> WWS.contextPath +
>>>>> WWS.filterPrefix + '/wicket/websocket';
>>>>>
>>>>> A workaround for you is to add url rewrite rule to Nginx to forward it to
>>>>> Tomcat.
>>>>>
>>>>> Please file an issue at JIRA and I'll see how this could be improved.
>>>>>
>>>>>
>>>>> Martin Grigorov
>>>>> Wicket Training and Consulting
>>>>> https://twitter.com/mtgrigorov
>>>>>
>>>>> On Wed, Oct 5, 2016 at 4:31 PM, Tom Götz <[hidden email]> wrote:
>>>>>
>>>>>> Hm, no solution yet … anyone got a working example or some hint maybe?
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>>
>>>>>>> On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
>>>>>>>
>>>>>>> Maybe answering my own question, but this here could help … I’ll give
>>>> it
>>>>>> a try:
>>>>>>> http://stackoverflow.com/questions/32287103/how-to-use-
>>>>>> nginx-as-a-proxy-for-wicket-application-using-websockets
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Tom
>>>>>>>
>>>>>>>
>>>>>>>> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Hi there,
>>>>>>>>
>>>>>>>> I have the following scenario:
>>>>>>>>
>>>>>>>> 1.
>>>>>>>> a Spring-Boot Wicket application with Tomcat running on Port 8080 that
>>>>>> uses Wicket WebSockets impl running in the servlet root context
>>>>>>>>
>>>>>>>> 2.
>>>>>>>> a ngnix server that proxies /MyLocation to the mentioned Wicket app
>>>>>>>>
>>>>>>>> As there is no servlet context involved, the generated WebSockets
>>>>>> endpoint url is generated by Wicket as: ws://mydomain.com/wicket/
>>>>>> websocket?pageId=1&wicket-ajax-baseurl=...
>>>>>>>>
>>>>>>>> I saw that this url is generated in BaseWebSocketBehavior#renderHead
>>>>>> by asking the request for the context path:
>>>>>>>>
>>>>>>>> String contextPath = component.getRequest().getContextPath();
>>>>>>>> variables.put("contextPath", contextPath);
>>>>>>>>
>>>>>>>> As I don’t have a contextPath, this fails:
>>>>>>>>
>>>>>>>> WebSocket connection to 'ws://mydomaon.com/wicket/
>>>>>> websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during
>>>>>> WebSocket handshake: Unexpected response code: 404
>>>>>>>>
>>>>>>>> Does the Wicket WebSocket API provide a way to handle such a scenario?
>>>>>> Currently, I’m studying the code but any pointer would be helpful …
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Tom
>>>>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

martin-g
A question : does Nginx send X-Forwarded-* headers ?
Which ones?

On Oct 5, 2016 7:16 PM, "Tom Götz" <[hidden email]> wrote:

> … so what I was trying to say (I’m not yet too deep into the websockets
> tech):
>
> isn’t it —in the described case— also necessary to configure the mount
> point of the WS endpoint?
>
>    Tom
>
>
>
> > On 05.10.2016, at 17:42, Tom Götz <[hidden email]> wrote:
> >
> > BTW, I already tried the following workaround without success:
> >
> > I did override WebSocketBehavior#renderHead and included a „patched“ JS
> init script that contained the contextPath that ngnix is forwarding to, so
> the generated JS looked like this:
> >
> > if (typeof(Wicket.WebSocket.appName) === "undefined") {
> >  jQuery.extend(Wicket.WebSocket, { pageId: 1, resourceName: '',
> >    baseUrl: ‚MyHomePage?1', contextPath: ‚/MyLocation', appName: ‚myApp',
> >    filterPrefix: '' });
> >  Wicket.WebSocket.createDefaultConnection();
> > }
> >
> > But still I got an 404 for the ws endpoint …
> >
> >   Tom
> >
> >
> >> On 05.10.2016, at 17:35, Tom Götz <[hidden email]> wrote:
> >>
> >> I created a JIRA for this: https://issues.apache.org/
> jira/browse/WICKET-6254
> >>
> >>  Tom
> >>
> >>
> >>> On 05.10.2016, at 17:31, Martin Grigorov <[hidden email]> wrote:
> >>>
> >>> The problem is that Nginx is configured to forward requests to
> /MyLocation
> >>> to Tomcat, and the application has no idea about this.
> >>>
> >>> Martin Grigorov
> >>> Wicket Training and Consulting
> >>> https://twitter.com/mtgrigorov
> >>>
> >>> On Wed, Oct 5, 2016 at 5:25 PM, Tom Götz <[hidden email]> wrote:
> >>>
> >>>> Hi Martin,
> >>>>
> >>>> what exactly is the problem in wicket-websocket-jquery.js? As I said,
> I
> >>>> have no contextPath, so I wouldn’t expect Wicket/wicket-websocket-
> jquery.js
> >>>> to know under which context the app is running. Shouldn’t I provide
> the
> >>>> context/mountPath somehow to the websocket initialization process?!
> >>>>
> >>>> Tom
> >>>>
> >>>>> On 05.10.2016, at 16:47, Martin Grigorov <[hidden email]>
> wrote:
> >>>>>
> >>>>> Hi Tom,
> >>>>>
> >>>>> The problem really is in wicket-websocket-jquery.js.
> >>>>> It does: url = protocol + '//' + document.location.host +
> >>>> WWS.contextPath +
> >>>>> WWS.filterPrefix + '/wicket/websocket';
> >>>>>
> >>>>> A workaround for you is to add url rewrite rule to Nginx to forward
> it to
> >>>>> Tomcat.
> >>>>>
> >>>>> Please file an issue at JIRA and I'll see how this could be improved.
> >>>>>
> >>>>>
> >>>>> Martin Grigorov
> >>>>> Wicket Training and Consulting
> >>>>> https://twitter.com/mtgrigorov
> >>>>>
> >>>>> On Wed, Oct 5, 2016 at 4:31 PM, Tom Götz <[hidden email]> wrote:
> >>>>>
> >>>>>> Hm, no solution yet … anyone got a working example or some hint
> maybe?
> >>>>>>
> >>>>>> Tom
> >>>>>>
> >>>>>>
> >>>>>>> On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
> >>>>>>>
> >>>>>>> Maybe answering my own question, but this here could help … I’ll
> give
> >>>> it
> >>>>>> a try:
> >>>>>>> http://stackoverflow.com/questions/32287103/how-to-use-
> >>>>>> nginx-as-a-proxy-for-wicket-application-using-websockets
> >>>>>>>
> >>>>>>> Cheers,
> >>>>>>> Tom
> >>>>>>>
> >>>>>>>
> >>>>>>>> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
> >>>>>>>>
> >>>>>>>> Hi there,
> >>>>>>>>
> >>>>>>>> I have the following scenario:
> >>>>>>>>
> >>>>>>>> 1.
> >>>>>>>> a Spring-Boot Wicket application with Tomcat running on Port 8080
> that
> >>>>>> uses Wicket WebSockets impl running in the servlet root context
> >>>>>>>>
> >>>>>>>> 2.
> >>>>>>>> a ngnix server that proxies /MyLocation to the mentioned Wicket
> app
> >>>>>>>>
> >>>>>>>> As there is no servlet context involved, the generated WebSockets
> >>>>>> endpoint url is generated by Wicket as: ws://mydomain.com/wicket/
> >>>>>> websocket?pageId=1&wicket-ajax-baseurl=...
> >>>>>>>>
> >>>>>>>> I saw that this url is generated in BaseWebSocketBehavior#
> renderHead
> >>>>>> by asking the request for the context path:
> >>>>>>>>
> >>>>>>>> String contextPath = component.getRequest().getContextPath();
> >>>>>>>> variables.put("contextPath", contextPath);
> >>>>>>>>
> >>>>>>>> As I don’t have a contextPath, this fails:
> >>>>>>>>
> >>>>>>>> WebSocket connection to 'ws://mydomaon.com/wicket/
> >>>>>> websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during
> >>>>>> WebSocket handshake: Unexpected response code: 404
> >>>>>>>>
> >>>>>>>> Does the Wicket WebSocket API provide a way to handle such a
> scenario?
> >>>>>> Currently, I’m studying the code but any pointer would be helpful …
> >>>>>>>>
> >>>>>>>> Cheers,
> >>>>>>>> Tom
> >>>>>>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Wicket WebSockets problem with servlet context

Don Ferguson
I don’t think NGINX sets the X-Forwarded headers by default, but it can be configured to do so.
In my http and https configurations, I have:

            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

-Don

> On Oct 9, 2016, at 2:53 AM, Martin Grigorov <[hidden email]> wrote:
>
> A question : does Nginx send X-Forwarded-* headers ?
> Which ones?
>
> On Oct 5, 2016 7:16 PM, "Tom Götz" <[hidden email]> wrote:
>
>> … so what I was trying to say (I’m not yet too deep into the websockets
>> tech):
>>
>> isn’t it —in the described case— also necessary to configure the mount
>> point of the WS endpoint?
>>
>>   Tom
>>
>>
>>
>>> On 05.10.2016, at 17:42, Tom Götz <[hidden email]> wrote:
>>>
>>> BTW, I already tried the following workaround without success:
>>>
>>> I did override WebSocketBehavior#renderHead and included a „patched“ JS
>> init script that contained the contextPath that ngnix is forwarding to, so
>> the generated JS looked like this:
>>>
>>> if (typeof(Wicket.WebSocket.appName) === "undefined") {
>>> jQuery.extend(Wicket.WebSocket, { pageId: 1, resourceName: '',
>>>   baseUrl: ‚MyHomePage?1', contextPath: ‚/MyLocation', appName: ‚myApp',
>>>   filterPrefix: '' });
>>> Wicket.WebSocket.createDefaultConnection();
>>> }
>>>
>>> But still I got an 404 for the ws endpoint …
>>>
>>>  Tom
>>>
>>>
>>>> On 05.10.2016, at 17:35, Tom Götz <[hidden email]> wrote:
>>>>
>>>> I created a JIRA for this: https://issues.apache.org/
>> jira/browse/WICKET-6254
>>>>
>>>> Tom
>>>>
>>>>
>>>>> On 05.10.2016, at 17:31, Martin Grigorov <[hidden email]> wrote:
>>>>>
>>>>> The problem is that Nginx is configured to forward requests to
>> /MyLocation
>>>>> to Tomcat, and the application has no idea about this.
>>>>>
>>>>> Martin Grigorov
>>>>> Wicket Training and Consulting
>>>>> https://twitter.com/mtgrigorov
>>>>>
>>>>> On Wed, Oct 5, 2016 at 5:25 PM, Tom Götz <[hidden email]> wrote:
>>>>>
>>>>>> Hi Martin,
>>>>>>
>>>>>> what exactly is the problem in wicket-websocket-jquery.js? As I said,
>> I
>>>>>> have no contextPath, so I wouldn’t expect Wicket/wicket-websocket-
>> jquery.js
>>>>>> to know under which context the app is running. Shouldn’t I provide
>> the
>>>>>> context/mountPath somehow to the websocket initialization process?!
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>>> On 05.10.2016, at 16:47, Martin Grigorov <[hidden email]>
>> wrote:
>>>>>>>
>>>>>>> Hi Tom,
>>>>>>>
>>>>>>> The problem really is in wicket-websocket-jquery.js.
>>>>>>> It does: url = protocol + '//' + document.location.host +
>>>>>> WWS.contextPath +
>>>>>>> WWS.filterPrefix + '/wicket/websocket';
>>>>>>>
>>>>>>> A workaround for you is to add url rewrite rule to Nginx to forward
>> it to
>>>>>>> Tomcat.
>>>>>>>
>>>>>>> Please file an issue at JIRA and I'll see how this could be improved.
>>>>>>>
>>>>>>>
>>>>>>> Martin Grigorov
>>>>>>> Wicket Training and Consulting
>>>>>>> https://twitter.com/mtgrigorov
>>>>>>>
>>>>>>> On Wed, Oct 5, 2016 at 4:31 PM, Tom Götz <[hidden email]> wrote:
>>>>>>>
>>>>>>>> Hm, no solution yet … anyone got a working example or some hint
>> maybe?
>>>>>>>>
>>>>>>>> Tom
>>>>>>>>
>>>>>>>>
>>>>>>>>> On 05.10.2016, at 15:57, Tom Götz <[hidden email]> wrote:
>>>>>>>>>
>>>>>>>>> Maybe answering my own question, but this here could help … I’ll
>> give
>>>>>> it
>>>>>>>> a try:
>>>>>>>>> http://stackoverflow.com/questions/32287103/how-to-use-
>>>>>>>> nginx-as-a-proxy-for-wicket-application-using-websockets
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Tom
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> On 05.10.2016, at 15:36, Tom Götz <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi there,
>>>>>>>>>>
>>>>>>>>>> I have the following scenario:
>>>>>>>>>>
>>>>>>>>>> 1.
>>>>>>>>>> a Spring-Boot Wicket application with Tomcat running on Port 8080
>> that
>>>>>>>> uses Wicket WebSockets impl running in the servlet root context
>>>>>>>>>>
>>>>>>>>>> 2.
>>>>>>>>>> a ngnix server that proxies /MyLocation to the mentioned Wicket
>> app
>>>>>>>>>>
>>>>>>>>>> As there is no servlet context involved, the generated WebSockets
>>>>>>>> endpoint url is generated by Wicket as: ws://mydomain.com/wicket/
>>>>>>>> websocket?pageId=1&wicket-ajax-baseurl=...
>>>>>>>>>>
>>>>>>>>>> I saw that this url is generated in BaseWebSocketBehavior#
>> renderHead
>>>>>>>> by asking the request for the context path:
>>>>>>>>>>
>>>>>>>>>> String contextPath = component.getRequest().getContextPath();
>>>>>>>>>> variables.put("contextPath", contextPath);
>>>>>>>>>>
>>>>>>>>>> As I don’t have a contextPath, this fails:
>>>>>>>>>>
>>>>>>>>>> WebSocket connection to 'ws://mydomaon.com/wicket/
>>>>>>>> websocket?pageId=1&wicket-ajax-baseurl=...' failed: Error during
>>>>>>>> WebSocket handshake: Unexpected response code: 404
>>>>>>>>>>
>>>>>>>>>> Does the Wicket WebSocket API provide a way to handle such a
>> scenario?
>>>>>>>> Currently, I’m studying the code but any pointer would be helpful …
>>>>>>>>>>
>>>>>>>>>> Cheers,
>>>>>>>>>> Tom
>>>>>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]