[Libwebsockets] a question about log info for 302 redirection

huangkaicheng huangkaicheng at huawei.com
Mon Nov 2 15:14:55 CET 2020


Thanks. I get relocated info successfully from “_WSI_TOKEN_CLIENT_URI”as you said .

Then, at the situation of relocating, I found that libwebsockets print quite a lot about" SSL Capable more service" logs after wss client establish success.



I want to know whether it is normal about " SSL Capable more service ".

What is meaning about “SSL Capable more service”?. And it is a bug or is is normal printed .



[cid:image002.jpg at 01D6B165.8EE6EC40]



-----邮件原件-----
发件人: Andy Green [mailto:andy at warmcat.com]
发送时间: 2020年11月1日 16:36
收件人: huangkaicheng <huangkaicheng at huawei.com>; libwebsockets <libwebsockets at ml.libwebsockets.org>
抄送: Chenyake <chenyake at huawei.com>
主题: Re: [Libwebsockets] 答复: a question libwebsockets client for 302 redirection







On 10/31/20 11:41 AM, huangkaicheng wrote:

> Sorry, maybe I doesn’t describe my question clearly just now.

>

> Server address is 121.37.223.76. ws client connect to

> server(121.37.223.76) when http handshaking. At the moment, Server



OK...



> response with 302 reason code to make ws client connect another

> address(58.222.56.63) with



OK...



> “v1/rtc/3423?appid=123213&userid=huangkaicheng&origindomain=mytest.com”.



So handling client redirects is a bit tricky, we already committed to using a specific wsi for the connection and told the user code what it is while it starts to do the DNS lookup and the tcp / tls connection, and we return from the client connection creation api.



If in fact we completed an http transaction on the wsi, and what we learned when we did it is that it wants us to do another one (which is completely different than a generic http transaction flow), this makes a problem for using a single wsi.  The relocation may be to a different server or a different path.



We could start a new wsi to do the new connection, but the user code doesn't expect that, he has been told it's coming on the old wsi, and he may have configured quite a lot of user code around that (C++ wrappers etc).



To square the circle, we have an internal api that "resets" the original wsi and fills it back up with info that was parsed out of the relocation

  Location: header, something similar happens with parsing data out of the client connection info struct and into "fake ah headers".  That covers stuff like the dns address string but also the new path part.



In both cases we have the information in an ephermeral form, either from the client connection info struct which may be on the stack, or from the

Location: header, and copy them into ah entries, so they have a place to live while the wsi connection proceeds asynchronously.



> ws can still redirect well with redirect url. But It seems that there

> is no way to get this redirect url(path) for caller when server

> response a redirection. In this situation, How can get the redirect

> url from server ? Is exist api or callback to get redirection info?



For the relocated path, we put it in _WSI_TOKEN_CLIENT_URI, it looks like you should be able to get it out of there using the normal lws_hdr apis



https://libwebsockets.org/git/libwebsockets/tree/lib/roles/http/client/client-http.c#n1643



We also stash it in _WSI_TOKEN_CLIENT_URI from the client connection info, I didn't try it but it should be OK to use that header and get the correct path part for both nonrelocated and relocated transactions.



-Andy



> redirect ads='58.222.56.63', port=443,

> path='v1/rtc/3423?appid=123213&userid=huangkaicheng&origindomain=mytes

> t.com',

> ssl = 1, pifds 0

>

> *发件人:*huangkaicheng

> *发送时间:*2020年10月31日17:38

> *收件人:*'libwebsockets' <libwebsockets at ml.libwebsockets.org<mailto:libwebsockets at ml.libwebsockets.org>>

> *抄送:*Chenyake <chenyake at huawei.com<mailto:chenyake at huawei.com>>

> *主题:*a question libwebsockets client for(302 redirect)

>

> Hi,

>

> Is there a way to get the path of redirect when ws client handshake,we

> meet  as follow ?  If not ,Could we add a callback to get this info.

> Thanks to anwser my question.

>

> redirect ads='58.222.56.63', port=443,

> path='v1/rtc/3423?appid=123213&userid=huangkaicheng&origindomain=mytes

> t.com',

> ssl = 1, pifds 0

>

> imap://andy@warmcat.com:993/fetch%3EUID%3E.INBOX%3E129515?header=quote

> body&part=1.1.2&filename=image001.png

>

>

> _______________________________________________

> Libwebsockets mailing list

> Libwebsockets at ml.libwebsockets.org<mailto:Libwebsockets at ml.libwebsockets.org>

> https://libwebsockets.org/mailman/listinfo/libwebsockets

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20201102/798cee48/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 68182 bytes
Desc: image002.jpg
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20201102/798cee48/attachment-0001.jpg>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: quite a lot about SSL Capable more service.txt
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20201102/798cee48/attachment-0001.txt>


More information about the Libwebsockets mailing list