Forum Discussion
Universal persistence: session-id inserted in HTTP Header
Hello Guys,
Well, the title pretty much explains it. I have a webservice that returns a session-id in the header, and I would like to use that session id to make the next HTTP request persist on the node that returned that id.
After surfing a lot, reading articles and posts and answers etc, I came up with this irule :
when HTTP_REQUEST {
if { [HTTP::header exists Session-ID] } {
set sessionid [HTTP::header value Session-ID]
persist uie $sessionid
}
}
However, it is not working. I'm testing this with curl, providing the session-id returned in the HTTP response, and in the second request (using the session ID provided) I hit some different server.
The first request:
curl -i -X POST 'http://10.10.19.10/blablalba' -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'conversation-id: blablabal' -H 'message-id: 63770dd6-68e7-4b8b-9647-948837593120' -d '{"calculationCriteria": {"recordLocator": "BLABLA"}}'
The headers in the response:
HTTP/1.1 200 OK
via: insertA
Date: Thu, 31 Aug 2017 22:06:05 GMT
Vary: Accept-Encoding
Server: Apache-Coyote/1.1
Message-ID: 63770dd6-68e7-4b8b-9647-948837593120
Session-ID: 3d0167ba9b0c460ebd845470a49bf9d6
The second request:
curl -i -X GET 'http://10.10.19.10/blablalba' -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'conversation-id: 698f7ff3-e7c0-466b-81e3-185a6c9a88ee' -H 'message-id: 63770dd6-68e7-4b8b-9647-948837593120' -H 'session-id: 3d0167ba9b0c460ebd845470a49bf9d6'
The response:
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Authorization: Bearer Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/ACPCRTC!ICESMSLB\/CRT.LB!-3237460263881640826!1205674!0!2
Conversation-ID: 698f7ff3-e7c0-466b-81e3-185a6c9a88ee
Date: Thu, 31 Aug 2017 22:17:33 GMT
Message-ID: 63770dd6-68e7-4b8b-9647-948837593120
Session-ID: 3d0167ba9b0c460ebd845470a49bf9d6
Content-Type: application/json
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Cnection: close
{"status":"Incomplete","type":"BusinessLogic","errorCode":"ERR.DCCI.APP.BUSINESS_ERROR","timeStamp":"2017-08-31T17:17:33",
"message":"Cannot find cached object for sessionID=3d0167ba9b0c460ebd845470a49bf9d6 in getTransaction"
So, the persistence didn't work. Notice that se session id remains the same in the following requests/responses.
Thoughts ?
Thanks, Fabian
- Dicky_Moe_13167
Nimbostratus
I was just looking at the persistence records, and there isn't any record after the 1st request. So that is where the problem is. I need to add a persistence record when the HTTP_RESPONSE event happens.
So I wrote:
when HTTP_RESPONSE { if { [HTTP::header exists Session-ID] } { set sessionid [HTTP::header value Session-ID] persist uie $sessionid } }
But I get this error:
Failure when receiving data from the peer
- cjunior
Nacreous
Hi, You need to check first on header responses. You could try like this:
when HTTP_REQUEST { if { [HTTP::header exists Session-ID] } { Back to the server persist uie [HTTP::header value Session-ID] } } when HTTP_RESPONSE { if { [HTTP::header exists Session-ID] } { persist on the server persist add uie [HTTP::header value Session-ID] } }
Regards.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com