Forum OpenACS Development: XML-RPC HTTP 302

Collapse
Posted by Iuri Sampaio on
Hi there,

I've installed and configured xml-rpc properly on my OACS box. Yesterday, everything was working fine but today the request started to return HTTP 302. What is even more curious is the behavior of it. It returns 302 in the first attempt, but the second returns HTTP200. See logs bellow.

Whether running NaviServer directly on port 80, or bellow NGINX(80) and NS(8000). it returns the same behavior.

What would be blocking the very first access to return 302, if yesterday was working just fine?

The RPC2 method is very simple, just for testing purposes.

catch {xmlrpc::remote_call http://1c.1contact.ch/RPC2 ws_annonces.soma -int 3 -int 11 } result

ad_proc -public ws_robot.sum {
    a
    b
} {
    It returns the sum result of a and b

} {
    ns_log Notice "Running ad_proc 1c_annonces.sum ..."
    set result [expr ${a} + ${b}]
    ns_log Notice "RESULT $result"
    return $result
}
Best wishes,
Iuri
[07/Apr/2017:14:35:02][27312.7fc6f5ffb700][-sched:idle0-] Notice: starting
[07/Apr/2017:14:35:03][27312.7fc6f77fe700][-driver:nssock_v4-] Notice: ... sockAccept accepted 3 connections
[07/Apr/2017:14:35:03][27312.7fc6f77fe700][-driver:nssock_v4-] Notice: ... sockAccept accepted 2 connections
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: Running TCL script test_ws.tcl
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Warning: ns_httpopen POST http://1c.1contact.ch/RPC2 d3 30 {ws_annonces.soma311} is deprecated. Use 'ns_http' instead!
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: sock32 sock33 d4
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE1
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE2 - sock33
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE3 - d4
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE4
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE 302
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Warning: ns_httpopen POST http://1c.1contact.ch/RPC2/ d4 30 {ws_annonces.soma311} is deprecated. Use 'ns_http' instead!
[07/Apr/2017:14:35:03][27312.7fc70e221700][-conn:1contact:0-] Notice: Running ad_proc 1c_annonces.soma ...
[07/Apr/2017:14:35:03][27312.7fc70e221700][-conn:1contact:0-] Notice: RESULT 14
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: sock32 sock33 d5
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE1
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE2 - sock33
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE3 - d5
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE4
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: HERE 200
[07/Apr/2017:14:35:03][27312.7fc70da20700][-conn:1contact:1-] Notice: 14
Collapse
2: Re: XML-RPC HTTP 302 (response to 1)
Posted by Iuri Sampaio on
So far,

in a whole new installation from scratch, from cvs head, I've got the very same bug. HTTP 302 then HTTP 200. Why does xml-rpc always answer with 302 at first?

Using a simple and functional xml-rpc remote call from lars-blogger

catch {xmlrpc::remote_call http://www.evex.co/RPC2 blogger.newPost -string "dsdsddfrerevgrtere" -int 1197 -string "mailto:iuri@iurix.com"; -string "GDGKGJEBSJjvijficFI$#44r45345" -string "text body" -boolean true} result

192.199.241.135 - - [09/Apr/2017:20:57:00 -0400] "POST /RPC2 HTTP/1.0" 302 299 "-" "NaviServer-Tcl/4.99"
192.199.241.135 - - [09/Apr/2017:20:57:00 -0400] "POST /RPC2/ HTTP/1.0" 200 122 "-" "NaviServer-Tcl/4.99"
179.34.179.254 - - [09/Apr/2017:20:57:05 -0400] "GET /test-ws HTTP/1.1" 502 575 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36"

Collapse
3: Re: XML-RPC HTTP 302 (response to 2)
Posted by Gustaf Neumann on
Iuri: "Why does xml-rpc always answer with 302 at first?"

Probably, the xml-rpc package is mounted at your instance at __LOCATION__/RPC2/. As always in OpenACS, if one navigates to a mounted package via e.g. __LOCATION__/RPC (without trailing slash), one is redirected to __LOCATION__/RPC/ (with trailing slash).

In your case, when you change the URL in the RPC requester to http://www.evex.co/RPC2/ i would expect that the 302 redirect will disappear.

Hope this helps
-gn

Collapse
4: Re: XML-RPC HTTP 302 (response to 3)
Posted by Iuri Sampaio on
Thanks Gustaf! It works now.

I need to pay more attention. Perhaps I need to rest a little bit.
It was bearing me to madness since it was working in the browser ( with auto redirection) but my python script was breaking ( which doesn't have auto redirection and attempts only once) .

Trailing slash... Arrrrg! 😊

Best wishes,