I have a perl code that sends a reminder sms via Net::UCP package. It worked so far, until now, I started to get negative acknowledgement with 02 reason code. The EMI UCP documentation says, it refers to syntax error, but I don't know why. It worked for like 6 months. Here is the sent string:
02/00454/O/51/0036204802483/36303444080/////////////////3/8/5469737A74656C7420DC677966656CFC6E6B21200A0A54E16AE96B6F7A7461746A756B2C20686F6779206C656AE17261746920534D5320737A6F6C67E16C746174E173756E6B20746563686E696B6169206F6B6F6B62F36C206D6567737A3F6E696B2E200A4BE9726AFC6B2C206B69656D656C74656E2066696779656C6A656E2061207AE16C6F676A65677965206C656AE1726174E172612E200A0A5469737A74656C657474656C3A200A42C1562050E96E7AFC677969205A7274////1////1139/////04
And here is what I receive:
02/00022/R/51/N/02//07
My question is where is the syntax error in the sent string? Thanks in advance!
It was the MB parameter that was set to 8. I also noticed that a new message was uploaded that was too long, was longer than 160 characters, so I told the client to change it.
I'm trying to get MassPay working on my website. Here's my code:
http://pastebin.com/rNGzXrq0
But it's uncomprehensible, as it gives me the error response "the number of input records is less than or equal to zero" even If there is 2 input records in the request.
How can I solve this ?
Thank you for your help :)
I noticed you have
'L_ATM0' => '5.00',
It should be
'L_AMT0' => '5.00',
The full list of PayPal API error messages can be found here.
The "long message" that you're receiving from the API is very poorly worded to the point of being almost useless.
Thankfully, the "short message" is a lot more helpful:
Transaction refused because of an invalid argument. See additional error messages for details.
So the error in question is related to a bad argument being passed.
I'm sending a new order message (message type 'D') to my FIX server and it's getting kicked back from 'pre-validation' on the server with the response that the stated message body length does not match the actual message.
In a text editor it appears that the declared body length DOES match the message length (measured between the bodylength tag value, and the delimiter preceding the checksum)
Below is the message I am sending (with sensitive data replaced with an equal number of 'x' characters):
8=FIX.4.4^9=183^35=D^34=2^49=xxxxxxxxxxx^52=20130927-19:57:35.771^56=xxx^1=xxxxxxxx^11=123^21=1^38=10^40=1^52=20130927-19:57:35.770^54=1^55=MSFT^59=1^60=20130927-19:57:35.771^100=xxxx^553=xxxxxxxxxx^10=234^
Here is the Business Reject Message (type 'j') that I immediately get back:
8=FIX.4.4^9=126^35=j^49=xxx^56=xxxxxxxxxxx^34=3^52=20130927-16:09:05.888^43=N^372=D^58=PreValidate Failed body lengh problem^380=4^379=2^45=0^10=007^
(the typo is theirs, not mine)
Here is the code used to build the message:
message = fix.Message()
header = message.getHeader()
header.setField(fix.BeginString('FIX.4.4'))
header.setField(fix.SenderCompID('xxxxxxxxxxx'))
header.setField(fix.TargetCompID('xxx'))
header.setField(fix.MsgType('D'))
message.setField(fix.Account(DEMO_Account_Number))
message.setField(fix.HandlInst('1')) #only valid value is '1'
message.setField(fix.OrderQty(int(Test_Order_Qty)))
message.setField(fix.OrdType('1')) #1=Market, 2=Limit, 3=Stop,4=StopLimit, P=TrailingStop, T=TTO
message.setField(fix.SendingTime(1))
message.setField(fix.Side('1')) #1=Buy, 2=Sell, 5=Sell Short, and 6=Sell Short Exempt.
message.setField(fix.Symbol('MSFT'))
message.setField(fix.TimeInForce('1')) # 0 = Day , 1 = GTC.................
message.setField(fix.TransactTime(1))
message.setField(fix.ExDestination('xxxx'))
message.setField(fix.Username(UserName))
fix.Session_sendToTarget(message)
What might be going wrong here? Why is the server kicking it back?
Thanks.
I was able to add a recipient to an envelope with a recipientId that was the HASH of the recipient's email address (50a5ae9b6d8889c1fda3f140621b448b). However, I was not able to add tabs to that recipient. I was able to edit the recipient name and email address, so the system seems to be able to recognize the recipientId. It appears to be a problem with the recipientId in the URL since adding tabs is the only REST API call that uses the recipientId in the URL.
After more testing, I found that there is a limit of 32 characters to the length of the recipientId but you can still edit the recipient and assign a recipientId that is not valid (alphanumeric and/or greater than 32 characters).
I'm seeing different results, and seeing the system act as expected here. First off, if I try to add a 32 digit number for the recipientId such as
12345678901234567890123456789012
I'm able to add the recipient just fine, then subsequently modify their tabs. Next, if I try an alpha numeric string, such as (notice the z at the end)
1234567890123456789012345678901z
The system generates an error stating INVALID_RECIPIENT_ID - A recipient ID is missing or invalid. I also get this error if I try a completely numeric number that is greater than 32 digits in length.
Please re-test and confirm your results, as this appears to be functioning as designed.
In our Windows C++ application I am using InitializeSecurityContext() client side to open an schannel connection to a server which is running stunnel SSL proxy. My code now works, but only with a hack I would like to eliminate.
I started with this sample code:http://msdn.microsoft.com/en-us/library/aa380536%28v=VS.85%29.aspx
In the sample code, look at SendMsg and ReceiveMsg. The first 4 bytes of any message sent or received indicates the message length. This is fine for the sample, where the server portion of the sample conforms to the same convention.
stunnel does not seem to use this convention. When the client is receiving data during the handshake, how does it know when to stop receiving and make another call to InitializeSecurityContext()?
This is how I structured my code, based on what I could glean from the documentation:
1. call InitializeSecurityContext which returns an output buffer
2. Send output buffer to server
3. Receive response from server
4. call InitializeSecurityContext(server_response) which returns an output buffer
5. if SEC_E_INCOMPLETE_MESSAGE, go back to step 3,
if SEC_I_CONTINUE_NEEDED go back to step 2
I expected InitializeSecurityContext in step 4 to return SEC_E_INCOMPLETE_MESSAGE if not enough data was read from the server in step 3. Instead, I get SEC_I_CONTINUE_NEEDED but an empty output buffer. I have experimented with a few ways to handle this case (e.g. go back to step 3), but none seemed to work and more importantly, I do not see this behavior documented.
In step 3 if I add a loop that receives data until a timeout expires, everything works fine in my test environment. But there must be a more reliable way.
What is the right way to know how much data to receive in step 3?
SChannel is different than the Negotiate security package. You need to receive at least 5 bytes, which is the SSL/TLS record header size:
struct {
ContentType type;
ProtocolVersion version;
uint16 length;
opaque fragment[TLSPlaintext.length];
} TLSPlaintext;
ContentType is 1 byte, ProtocolVersion is 2 bytes, and you have 2 byte record length. Once you read those 5 bytes, SChannel will return SEC_E_INCOMPLETE_MESSAGE and will tell you exactly how many more bytes to expect:
SEC_E_INCOMPLETE_MESSAGE
Data for the whole message was not read from the wire.
When this value is returned, the pInput buffer contains a SecBuffer structure with a BufferType member of SECBUFFER_MISSING. The cbBuffer member of SecBuffer contains a value that indicates the number of additional bytes that the function must read from the client before this function succeeds.
Once you get this output, you know exactly how much to read from the network.
I found the problem.
I found this sample:
http://www.codeproject.com/KB/IP/sslsocket.aspx
I was missing the handling of SECBUFFER_EXTRA (line 987 SslSocket.cpp)
The SChannel SSP returns SEC_E_INCOMPLETE_MESSAGE from both InitializeSecurityContext and DecryptMessage when not enough data is read.
A SECBUFFER_MISSING message type is returned from DecryptMessage with a cbBuffer value of the amount of desired bytes.
But in practice, I did not use the "missing data" value. The documentation indicates the value is not guaranteed to be correct, and is only a hint for developers can use to reduce calls.
InitalizeSecurityContext MSDN doc:
While this number is not always accurate, using it can help improve performance by avoiding multiple calls to this function.
So I unconditionally read more data into the same buffer whenever SEC_E_INCOMPLETE_MESSAGE was returned. Reading multiple bytes at a time from a socket.
Some extra input buffer management was required to append more read data and keep the lengths right. DecryptMessage will modify the input buffers' cbBuffer properties when it fails, which surprised me.
Printing out the buffers and return result after calling InitializeSecurityContext shows the following:
read socket:bytes(5).
InitializeSecurityContext:result(80090318). // SEC_E_INCOMPLETE_MESSAGE
inBuffers[0]:type(2),bytes(5).
inBuffers[1]:type(0),bytes(0). // no indication of missing data
outBuffer[0]:type(2),bytes(0).
read socket:bytes(74).
InitializeSecurityContext:result(00090312). // SEC_I_CONTINUE_NEEDED
inBuffers[0]:type(2),bytes(79). // notice 74 + 5 from before
inBuffers[1]:type(0),bytes(0).
outBuffer[0]:type(2),bytes(0).
And for the DecryptMessage Function, input is always in dataBuf[0], with the rest zeroed.
read socket:bytes(5).
DecryptMessage:len 5, bytes(17030201). // SEC_E_INCOMPLETE_MESSAGE
DecryptMessage:dataBuf[0].BufferType 4, 8 // notice input buffer modified
DecryptMessage:dataBuf[1].BufferType 4, 8
DecryptMessage:dataBuf[2].BufferType 0, 0
DecryptMessage:dataBuf[3].BufferType 0, 0
read socket:bytes(8).
DecryptMessage:len 13, bytes(17030201). // SEC_E_INCOMPLETE_MESSAGE
DecryptMessage:dataBuf[0].BufferType 4, 256
DecryptMessage:dataBuf[1].BufferType 4, 256
DecryptMessage:dataBuf[2].BufferType 0, 0
DecryptMessage:dataBuf[3].BufferType 0, 0
read socket:bytes(256).
DecryptMessage:len 269, bytes(17030201). // SEC_E_OK
We can see my TLS Server peer is sending TLS headers (5 bytes) in one packet, and then the TLS message (8 for Application Data), then the Application Data payload in a third.
You must read some arbitrary amount the first time, and when you receive SEC_E_INCOMPLETE_MESSAGE, you must look in the pInput SecBufferDesc for a SECBUFFER_MISSING and read its cbBuffer to find out how many bytes you are missing.
This problem was doing my head in today, as I was attempting to modify my handshake myself, and having the same problem the other commenters were having, i.e. not finding a SECBUFFER_MISSING. I do not want to interpret the tls packet myself, and I do not want to unconditionally read some unspecified number of bytes. I found the solution to that, so I'm going to address their comments, too.
The confusion here is because the API is confusing. Ordinarily, to read the output of InitializeSecurityContext, you look at the content of the pOutput parameter (as defined in the signature). It's that SecBufferDesc that contains the SECBUFFER_TOKEN etc to pass to AcceptSecurityContext.
However, in the case where InitializeSecurityContext returns SEC_E_INCOMPLETE_MESSAGE, the SECBUFFER_MISSING is returned in the pInput SecBufferDesc, in place of the SECBUFFER_ALERT SecBuffer that was passed in.
The documentation does say this, but not in a way that clearly contrasts this case against the SEC_I_CONTINUE_NEEDED and SEC_E_OK cases.
This answer also applies to AcceptSecurityContext.
From MSDN, I'd presume SEC_E_INCOMPLETE_MESSAGE is returned when not enough data is received from server at the moment. Instead, SEC_I_CONTINUE_NEEDED returned with InBuffers[1] indicating amount of unread data (note that some data is processed and must be skipped) and OutBuffers containing nothing.
So the algorithm is:
If SEC_I_CONTINUE_NEEDED returned, check type of InBuffers[1]
If it is SECBUFFER_EXTRA, handle it (move InBuffers[1].cbBuffer bytes to the beginning of input buffer) and jump to next recv & InitializeSecurityContext iteration
If OutBuffers is not empty, send its contents to server