I searched everywhere in U2 Universe manual but I don't see any example of how to close the connection after calling a submitRequest function. Does anyone knows?
Asked
Active
Viewed 742 times
1
-
1Please post a snippet of code that shows where you're calling submitRequest – webthaumaturge Aug 01 '14 at 20:46
-
Below is the code are the code, if the errCode is 0, it's calling the next statement in the program. Line 232: errCode = setHTTPDefault("version", "1.1") Line 250: errCode = creteSecurityContext(securityContext, version) Line 268: errCode = addAuthenticationRule(securityContext, "2", "VerificationStrength", "generous") Line 288: errCode = createSecureRequest(mandrillPostUrl, httpMethod, requestHandle, securityContext) Line 306: errCode = submitRequest(requestHandle, httpTimeOut, mandrillDcdRec, responseHeaders, responseData, httpStatus) – user3464522 Aug 14 '14 at 20:23
1 Answers
1
There is no need to close the connection because the disconnect (and connect) is built into submitRequest.
If you turn on protocol logging, you can see that, after reading the entire response, Universe closes the connection as part of submitRequest:
0574: 11/23/2010 16:18:41 [ 7440 6596 ] SSL read: status=NONE,len=7866
0575: 11/23/2010 16:18:41 [ 7440 6596 ] Socket 23dbe20: 7866 chars read
0576: 11/23/2010 16:18:41 [ 7440 6596 ] HTTP_MOREDATA: bytes_read=7866, total_re
ad=16058, bytes_remainig=0
0577: 11/23/2010 16:18:41 [ 7440 6596 ] HTTP_MOREDATA: data completely read
0578: 11/23/2010 16:18:41 [ 7440 6596 ] HTTP_FINISH
0579: 11/23/2010 16:18:41 [ 7440 6596 ] in destroySocket(): socket 23dbe20 refs=
1
0580: 11/23/2010 16:18:41 [ 7440 6596 ] Socket 23dbe20 closed and freed: 0(No er
ror) 0(No error)
0581: 11/23/2010 16:18:41 [ 7440 6596 ] Host 23711e0 freed
You can also see Universe opening the connection as part of submitRequest:
0067: 11/23/2010 16:18:39 [ 7440 6596 ] HTTP_START: timeout=60000
0068: 11/23/2010 16:18:39 [ 7440 6596 ] HTTP_CONNECT
0069: 11/23/2010 16:18:39 [ 7440 6596 ] new host 23711e0:www.example.org:4
43 allocated (proxy:no)
0070: 11/23/2010 16:18:39 [ 7440 6596 ] host www.example.org:443 not found
in hostList
0071: 11/23/2010 16:18:39 [ 7440 6596 ] socket 23dbe20 allocated
0072: 11/23/2010 16:18:39 [ 7440 6596 ] start SSLbinding ...
Just as a helpful reference, here's an example for how to turn on protocol logging:
LOGRECORDID = "MY_LOG_IN_THE_ROOT_OF_THE_ACCOUNT.LOG"
RESULT = protocolLogging(LOGRECORDID,"ON",10)
ERROR = submitRequest(requestHandle, httpTimeOut, mandrillDcdRec, responseHeaders, responseData, httpStatus)
RESULT = protocolLogging(LOGRECORDID,"OFF",0)

webthaumaturge
- 1,198
- 1
- 11
- 23
-
Thank webthaumaturge for the info., I also need to change the headers to be "application/json" so I used the following api but it doesn't seem to work. Am I doing it right? errCode=setRequestHeader(requestHandle, "Content-Type", "application/json") – user3464522 Sep 12 '14 at 19:12
-
That looks correct for setting the header. You probably know this already, but make sure you're using that code before running submitRequest(). Please post your protocol logging result if you continue to have trouble. – webthaumaturge Sep 15 '14 at 19:57