I am struggling to get AT commands working that will get the 3G SIM5230 module to make a clean HTTP request. When I build and send what I believe is a good request, I do not get a response from the web server, only the error +CHTTPACT: 237. I can get the module to send an invalid post (simply add a space in front of the POST in the command), and I get a response back from a web server 400, telling me it is an invalid http request. Anyone out there successfully doing HTTP POST commands with this module?
Model: SIMCOM_SIM5320A
Revision: SIM5320A_V1.5
I also had trouble POST and GET 'ing with the SIM5320a module. While this code is for GET, similar code can be used for POST.
I found the tricky bit was what keystrokes to send after the AT+CHTTPSSEND=86 command, and how many characters to include in this (NOTE that the 86 is crucial - it is the number of characters plus 6 = for carriage return and line feeds). It took a while to work out that you need two carriage returns and line feeds at the end.
I used TERATERM for testing. I have now made some simple code for my arduino uno connected to a SIM5320a (this has been running for over a week now, and gets data every hour). If anyone wants this code, send me a request.
TERATERM + SIM5320a
//This program is for a SIM5320A connection using TeraTerm (I am running this through an Arduino Uno that has been uploaded with a AT port-through script). The items in brackets are the keystrokes I used to make the request run. The information after -> is the expected result.
//SETUP
AT+CGDCONT=1,"IP","INSERT_YOUR_APN","0.0.0.0" (return) -> OK
AT+CGSOCKCONT=1,"IP","INSERT_YOUR_APN" (return) -> OK
AT+CSOCKSETPN=1 (return) -> OK
//Start HTTPS session
AT+CHTTPSSTART (return) -> OK
//Open HTTPS session at server
AT+CHTTPSOPSE="www.XXXXXXXXXXXXXXXX.com.au",80,1 (return) -> OK
//Send request - NOTE that the 86 is crucial - it is the number of characters in what you want to send plus 6 (6 carriage return and line feeds)
AT+CHTTPSSEND=86 (return) -> >
GET /SensorE.php?temp=11111&EC=3333 HTTP/1.1
(Ctrl M)
(Ctrl J)
Host: www.XXXXXXXXXXXXXXXX.com.au:80
(Ctrl M)
(Ctrl J)
(Ctrl M)
(Ctrl J) -> OK +CHTTPS: RECV EVENT
//Receive request
AT+CHTTPSRECV=4000 (return) -> lots of stuff we hope, but should contain the returned data from your website
//Close session at server (but will automatically after it gets a nice recv)
AT+CHTTPSCLSE (return) -> OK or error - it is ok if error pops up here
//Stop the http service
AT+CHTTPSSTOP (return) -> OK
//Power down the module
AT+CPOF
Please verify your actual model because you said you have the SIMCOM5320A Model and asked about the SIM5230A.
If you have the SIMCOM5320A I think you are getting that error because that AT Command is already deprecated.
You can check the SIMCOM5320A AT Commands here: AT Commands
Related
We have a simulator(client) and controller(server).
The controller sends a command signal through ModbusTCP to the simulator.
I want to emulate this controller on my computer.
What I have done
For the test, I wrote pymodbus Server script on my pc and pymodbus Client script on another PC. There was no problem to read holding and input register from client pc.
I connected my clinet pc to controller(server) to know what kind of values I have to send to actual client(simulator). I found out that 8 registers(from 0 to 7) are used to store integer values.
I tried to establish a connection between my pc(sever) and simulator computer(client).I was able to establish a connection and send a response to the client.
Problem
I have no information about this client(simulator) because we have no access to the client script.
I found out that this client sends a request not only for the reading but also for writing.
When I use the holding register, I got an error "illegal data address." But the input register does not show any error. For this reason, I am using input_register to save a specific integer number.
I stored some values on input_register, but sever input_registers are written by client(simulator) as below.
write request from client(simulator)
polling server(pc) with modpoll software
Question
why write requests from the client(simulator) overwrite my input_register? As far as I know, input_register is used for only reading. I assume that I made a mistake in storing a variable on the input_register.
When I make a connection between controller and simulator, wireshark and modpoll show that client(simulator) reads registers (from 0 to 7). But when I make a connection between my server(pc) and client(simulator), my sever response with different register numbers as below. Resister number starts from 1000. Why does simulator request different register start number? ex) from 0: controller, from 1000: PC(sever)
First response from server(pc)
Update! my server can respond with the values but with wrong register numbers. I changed starting register number(0 -->1000).
I attached picture.
response from server(pc)
Please advice me on this issue.
I will do my best effort to solve this issue.
'''
from pymodbus.server.sync import StartTcpServer
from pymodbus.datastore import ModbusSequentialDataBlock
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
from pymodbus.device import ModbusDeviceIdentification
from pymodbus.datastore import ModbusSequentialDataBlock, ModbusSparseDataBlock
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
from pymodbus.transaction import ModbusRtuFramer, ModbusBinaryFramer
#%%
import logging
FORMAT = ('%(asctime)-15s %(threadName)-15s'
' %(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger()
log.setLevel(logging.DEBUG)
#%%
#%%
def run_server():
store = ModbusSlaveContext(
ir=ModbusSequentialDataBlock(0, [28692,28692,28692,28692,28692,65508,65508,65508
]),zero_mode=True)
context = ModbusServerContext(slaves=store, single=True)
StartTcpServer(context, address=("192.168.1.231", 502))
identity = ModbusDeviceIdentification()
identity.VendorName = 'Pymodbus'
identity.ProductCode = 'PM'
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/'
identity.ProductName = 'Pymodbus Server'
identity.ModelName = 'Pymodbus Server'
identity.MajorMinorRevision = '1.0'
#%%
if __name__ == "__main__":
run_server()
'''
Dear MarcosG,
I attached screen-shots from wireshark as below.
write request from clinet(simulator)
- as you can see clinet(simulator) send a request for writing and register number start from 256.
read response from server(controller)
- Sever(controller) responds to the request of clinet for reading. And it send a respond and register number start from 256.
polling sever with modpoll software
- we can look the values on the registers of sever, as you can see, values are stored in the register from 0 to 7. These values are from controller lever. If I adjust lever, these values are changing.
requested address_exel_File
- We have one more simulator(bridge2). It shows the same register number with both controller(server) and pc(server).
problem: the actual registers of sever which store values are from 0 to 7. However, Client and server communicate with different registers (from 256) which contain "0" values. But there is no issue for adjusting parameters of ship on the simulator.
Best regards
Byeon Seongsu
When our service fails to deliver an email, the rejection notification returned to the sender contains the stack trace of the code that failed. Is there a way to send the delivery notification, without the attached errors?
We have a postfix server that handles incoming emails in a catchall python script. That script uploads the email to one of our services and throws an exception in case it failed.
This is the template we are using
failure_template = <<EOF
Charset: us-ascii
From: MAILER-DAEMON (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
Postmaster-Subject: Postmaster Copy: Undelivered Mail
This is the mail system at host $myhostname.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to <postmaster>
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
EOF
Expected result would be just the template notification, without the strack trace of the catch-all script.
The mail server simply includes in the bounce whatever your Python program displays on its standard error. Maybe call the script via a wrapper which saves the standard error to a sane place (or even discards it, if you are sure it never contains anything useful).
#!/bin/sh
python3 /path/to/deliver.py 2>>/var/log/deliver.log
Your mail server obviously needs to have write access to the log, and you'll probably want to set up periodic log rotation for the file.
Probably a better overall approach is for the Python program to not crash.
Quectell M66 doesn't let me input the data which I need to send to a LAMP Web Server through HTTP POST method. After entering the AT+QHTTPPOST=10,50 command Quectell outputs: CNNECT and it doesn't let me input the data at all and after sometime gives +CME ERROR:3825 which is timeout error. My codes are:
AT+CGATT=1
AT+QIFGCNT=0
AT+QICSGP=1,"bsnlnet"
AT+QIREGAPP
AT+QIACT
AT+QILOCIP
AT+QHTTPURL=66,30
my_66byte_long_URL
AT+QHTTPPOST=10,50
AT+QIDEACT
Recently, I had found the answer to my own problem and I am posting it here so that it could be of help to others.
enter link description here
Thanks in advance for any help received.
I want to allow our client to enter a URL into a text field which then checks whether the URL exists and works.
There are 3 possible outcomes I want to check for:
A status of 200 - OK,
A status of 500 - Server Error,
Or a status of 404 - page not found.
When executing the following code in ASP classic I get a status code of 12007 when I should be getting 404. Is this because it can't find a webserver to return a code of 404?
Function CheckURL(vURL)
ON ERROR RESUME NEXT
Set oXML=Server.CreateObject("MSXML2.XMLHTTP") : oXML.Open "POST",vURL,false : oXML.Send()
CheckURL = oXML.status
Set oXML = nothing
End Function
Or is something amiss here. What status codes am I likely to see other than the standard mentioned above.
The 12007 is a Windows HTTP error which means name hasn't been resolved. You can't get a 200, 404, 500 or any such thing if the host name can't be resolved to an IP address or a connection can't be established to that IP address. In these cases you will get error codes in the 12000s range which aren't HTTP status codes but are windows exception numbers.
See this list for a list of these exception numbers.
BTW, XMLHTTP is not a safe item object to use in ASP. Also why are you using a POST? This is the code I would use:-
Function CheckURL(vURL)
On Error Resume Next
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.3.0")
xhr.Open "HEAD", vURL, false
xhr.Send
CheckURL = xhr.status
End Function
Using HEAD allows you test the URL without actually downloading a potentially large entity body.
Can someone help me with this problem that occurs whenever you run a TRIGGER, but works in a normal PROCEDURE?
TRIGGER:
create or replace
procedure testeHTTP(search varchar2)
IS
Declare
req sys.utl_http.req;<BR>
resp sys.utl_http.resp;<BR>
url varchar2(500);
Begin
url := 'http://www.google.com.br';
dbms_output.put_line('abrindo');
-- Abrindo a conexão e iniciando uma requisição
req := sys.utl_http.begin_request(search);
dbms_output.put_line('preparando');
-- Preparandose para obter as respostas
resp := sys.utl_http.get_response(req);
dbms_output.put_line('finalizando response');
-- Encerrando a comunicação request/response
sys.utl_http.end_response(resp);
Exception
When Others Then
dbms_output.put_line('excecao');
dbms_output.put_line(sys.utl_http.GET_DETAILED_SQLERRM());
End;
close your user session and then the problem is fixed.
Internal there is a limit from 5 http requests.
Might a problem is the missing: utl_http.end_response
or an exception in the app and not a close from the resp object.
modify the code like that:
EXCEPTION
WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
UTL_HTTP.END_RESPONSE(resp);
you need to close your requests once you are done with them, it does not happen automatically (unless you disconnect form the db entirely)
It used to be utl_http.end_response, but I am not sure if it is the same api any more.
Usually we need UTL_HTTP.END_RESPONSE(resp); to avoid of ORA-29270: too many open HTTP requests, but I think I reproduced the problem of #Clóvis Santos in Oracle 19c.
If web-service always returns status 200 (success) then too many open HTTP requests never happens. But if persistent connections are enabled and web-service returns status 404, behavior becomes different.
Let`s call something that always return 404.
First call of utl_http.begin_request returns normally and opens new persistent connection. We can check it with select utl_http.get_persistent_conn_count() from dual;. Second call causes an exception inside utl_http.begin_request and persistent connection becomes closed. (Exception is correctly handled with end_response/end_request).
If I continue then each odd execution returns 404 normally and each even execution gives an exception (handled correctly of course).
After some iterations I get ORA-29270: too many open HTTP requests. If web-service returns status 200 everything goes normally.
I guess, it happens because of the specific web-service. Probable it drops persistent connection after 404 and doesn't after 200. Second call tries to reuse request on persistent connection but it doesn't exist and causes request leak.
If I use utl_http.set_persistent_conn_support (false, 0); once in my session the problem disappears. I can call web-service as many times as I need.
Resolution:
Try to switch off persistent connection support. Probable, on the http-server persistent connections work differently for different requests. Looks like a bug.