FIX server rejecting message saying there is a body length error? - quickfix

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.

Related

How do I translate the following POST request into ESP8266 AT-command format?

I've got a working local website that takes in HTML form data.
The fields are:
Temperature
Humidity
The server successfully receives the data and spits out a graph updated with the new entries.
Using a browser tool, I was able to capture the actual POST request as follows:
http://127.0.0.1:5000/add_data
Temperature=25.4&Humidity=52.2
Content-Length:30
Now, I want to migrate from using the human interface browser with manual entries to an ESP01 device using AT commands.
According to the ESP AT-commands documentation, a POST request is performed using the following command:
AT+HTTPCPOST=
Find the link below for the full description of the command.
I cannot seem to get this POST request working. The ESP01 device immediately returns an "ERROR" message without any delay, as though it did not even try to send the request, that the syntax might be wrong.
Among many variations, the following is my best attempt:
AT+HTTPCPOST="http://MYIPADDR:5000/add_data",30,2,"Temperature: 25.4","Humidity: 52.2"
With MYIPADDR above replaced with my IP address.
How do I translate a post request into ESP01 AT command format, and are there any prerequisites needed to be in place to perform such a request?
I did connect the ESP01 device to the WiFi network.
Here's the link to the POST AT command description:
https://docs.espressif.com/projects/esp-at/en/release-v2.2.0.0_esp8266/AT_Command_Set/HTTP_AT_Commands.html#cmd-httpcpost
The documentation says:
AT+HTTPCPOST=url,length[,<http_req_header_cnt>][,<http_req_header>..<http_req_header>]
Response:
OK
The symbol > indicates that AT is ready for receiving serial data, and you can enter the data now. When the requirement of message length
determined by the parameter is met, the transmission starts.
...
Parameters
: HTTP URL. : HTTP data length to POST. The maximum
length is equal to the system allocable heap size.
<http_req_header_cnt>: the number of <http_req_header> parameters.
[<http_req_header>]: you can send more than one request header to the
server.
You're sending:
AT+HTTPCPOST="http://MYIPADDR:5000/add_data",30,2,"Temperature: 25.4","Humidity: 52.2"
The length is 30. The problem is that everything after the length is HTTP header fields; you need to send the variables in the body. So the command is:
AT+HTTPCPOST="http://MYIPADDR:5000/add_data",30
followed on the next line by after the ESP-01 send the > character:
Temperature=25.4&Humidity=52.2
Because you passed 30 as the body length, the ESP-01 will read exactly 30 characters after the end of the AT command and send that data as the post body. If the size of that data changes (for instance, maybe the temperature is 2.2, so one digit less), you'll need to send the new length rather than 30.

FIX response with this error: Value is incorrect (out of range) for this tag

When I send the order request on the FIX server as :
8=FIXT.1.1|9=179|35=D|34=34|49=135|52=20200206-04:52:04.406|56=PSE|1=11101401117577|11=1580964724079|38=1000|40=2|44=10.5|54=1|55=AGI|59=0|60=20200206-12:52:04.406|453=1|448=13501100|447=C|452=12|10=009|)
The response that I receive is:
8=FIXT.1.1|9=000362|35=8|49=PSE|56=135|34=34|57=13501100|52=20200206-04:52:04.533|37=NONE|11=1580964724079|453=4|448=13501999|447=C|452=11|448=13501999|447=C|452=36|448=13501100|447=C|452=12|448=135|447=C|452=1|17=1904|150=8|39=8|103=99|1=11101401117577|55=AGI|54=1|38=1000|44=10.5|59=0|528=F|151=0|14=0|60=20200206-04:52:04.356|58=(293): **Orders are not being accepted at this time|10=020|)**
With the PSE error as:
<20200206-04:52:04, FIXT.1.1:135->PSE, error> (Rejecting invalid message: quickfix.IncorrectTagValue: Value is incorrect (out of range) for this tag, field=528 field=528: 8=FIXT.1.1|9=362|35=8|34=34|49=PSE|52=20200206-04:52:04.533|56=135|57=13501100|1=11101401117577|11=1580964724079|14=0|17=1904|37=NONE|38=1000|39=8|44=10.5|54=1|55=AGI|58=(293): Orders are not being accepted at this time|59=0|60=20200206-04:52:04.356|103=99|150=8|151=0|528=F|453=4|448=13501999|447=C|452=11|448=13501999|447=C|452=36|448=13501100|447=C|452=12|448=135|447=C|452=1|10=132|)
<20200206-04:52:04, FIXT.1.1:135->PSE, error> **(Reject sent for Message 34: Value is incorrect (out of range) for this tag**, field=528:528)
According to the documentary the value for 1 should be 14 digit trading account(1=xxxxxxxxxxxxxx) but when I give that, then I had receive the above error.So what value should be given for 1 so the response should be receive.
So what is the solution for this error?
The flow is as follows:
you send a NewOrderSingle
they reply with an ExecutionReport that they don't accept orders at that time
you (and not PSE) reject that ExecutionReport because tag 528 on the ExecutionReport that PSE sent contains a value that is not contained in your data dictionary.
What you need to do is either of
Read PSE's rules of engagement (i.e. their FIX spec) and add all needed tags and values to your data dictionary.
Configure your session to not validate incoming messages (setting ValidateIncomingMessage=N) but this means you would need to do validation by yourself if required. E.g. if you wanted to retrieve values from tag 150/ExecType then you can be sure that only values which are allowed in the data dictionary reach your application. With disabled validation you would need to do these checks by yourself.
Alternatively you could set RejectInvalidMessage=N which also will not reject the message but only log the warning with the validation error.

Email Error: missing or malformed local part

I am noticing that I get an email from my server each time an order is placed. It looks like the customer confirmation emails are not sending.
This is part of the error message:
A message that you sent contained one or more recipient addresses that were
incorrectly constructed:
=?utf-8?B?R3Vlc3Q=?= <>: missing or malformed local part
This address has been ignored. The other addresses in the message were
syntactically valid and have been passed on for an attempt at delivery.
------ This is a copy of your message, including all the headers. ------
To: =?utf-8?B?R3Vlc3Q=?= <>
Subject: =?utf-8?B?SW50ZWxsaWdlbnQgV29ya3Nob3A6IE5ldyBPcmRlciAjIDEwMDAwMDAzMA==?=
It looks like it’s only when the user checks out without registering
=?utf-8?B?R3Vlc3Q=?= <>: missing or malformed local part
The error message is quite obvious: There should be an email address between <>, but there is none. The local part is the part of the address before the #, and as there is nothing at all here, there is no local part. Thus your server is complaining.
You have to fix whatever application is trying to send mails to <> to get rid of the error.
The email address is not written in proper format, please use <>
I really don't Understand what you are trying to do. But This is what I found out playing around with this error.
$to = "'Name of Person' <email#example.com>";
$headers = "From: ".$_POST['theirName']."<".$_POST['theirEmail'].">\r\n";
$subject = $_POST['subject'];
$messageBody = $_POST['message']."\r\n ---\n This Message was sent from ".HOME." contact form.";
mail($to,$subject,$messageBody,$headers);
Notice that around the 'Name of Person' has single quotes. If you are trying to send emails with an additional name, title or anything else in front of the emails. With the single quotes will let PHP know that it is not an email but a string, and it will add the string but be ignored as an email, not giving you the error anymore.
The header where it states from does not need to have the single quotes.
=?utf-8?B?R3Vlc3Q=?= <-This line I don't know what it supposed to be doing.
But it's not an Email on the $to/$recipient and for that reason it giving the error. Once again, must have only emails: "email1#example.com, email2#example.com" other than that: 'String' with single quotes no error will produce...

Mavericks Mail Applescript Changes

Mavericks has been pretty good so far, but one truststy Applescript I'd been using for years decided it didn't wan to work anymore. The script is here:
tell application "Mail"
set the clipboard to (content of first message of ¬
inbox whose subject contains "2013-11-05") as string
end tell
The job of the script is to get the content from an email with a subject "J-List Reports 2013-11-05") (obviously this changes each day). If I change the script to look for "J-List reports" with no date it works fine, but it gets the wrong email since I can't specify the date (it looks for the first message that happens to have this string in the subject). If any numbers are in the Applescript, trying to force it to find the correct email, I get
"Mail got an error: can't get message 1 of inbox whose subject
contains 2013-11-05"
even though nothing else has changed.
Can anyone suggest a way to specify the correct mail, perhaps any mail whose subject contains "J-List reports" and whose month is 11 and whose day is 5? I spent a couple hours but couldn't get it to work for me.
This worked for me:
tell application "Mail"
content of message 1 of mailbox "[Gmail]/All Mail" of account "Gmail" where subject contains "2013-11-05"
end tell
set the clipboard to result
The messages are sorted from newest to oldest, so message 1 should be the newest message.
tell application "Mail" to messages of inbox and tell application "Mail" to messages of mailbox "INBOX" of account "Gmail" returned an empty list for some reason.
this works fine for me
tell application "Mail"
try
set the clipboard to (content of first message of ¬
inbox whose subject contains "2013-11-05") as string
on error errMsg
display dialog "an error: " & errMsg
end try
end tell
Try changing the string to something you know exists , I get the same error when I search for an email message where there are no matches. I suspect that you are not including the full error message here either
rror "Mail got an error: Can’t get message 1 of inbox whose subject contains \"2013-11-05\". Invalid index." number -1719
invalid index is important to a diagnosis because it tells us exactly what the problem is. There is no message that can be identified where the subject contains 2013-11-05
so you should use a try statement and then decided what to do from there.
Mail Version 7.0 (1816)
OS 10.9 build 13a603

DocuSign REST API Creating a Non-Numeric RecipientId Causes Invalid Recipient ID Error When Adding Tabs

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.