we are writing a component which sends message to a device thru one 3rd party interface.
i did used smpp client code to do that, but i want to make sure that what ever parameters i am passing is correct.
anyone correct me on below parameters if i am wrong.
sender = // 3rd party IP address
destination = // sim number which i want to send sms to it
ipAddress = "smpp.xyzwireless.com"; // provided by 3rd party
port = 2775;
systemId = srini // provided by 3rd party
password = srini // provided by 3rd party
and the with above details Bind() method will execute first then submit() and unBind() methods.
after you confirmed above parameters, could you confirm below possibility.
i want to keep the connection between ESME and SMSC alive for some long time. for that i am doing enquireLink() method.
i am placing this enquireLink method inside Timer() of java so it keeps check the connection for every 45 seconds and re-establish the disconnection time to next 60 seconds from time of enquireLink.
Am i thinking anything wrong here? correct me guys.
Thanks in advance.
If JSMPP implements opensmpp the same way other os-libs do, then sender will stand for an A-number — alpha-numeric or simply numeric string of no more that 11 bytes that represents your identity to a recipient.
You can think of it as your ESME sim number.
You might also need to specify source_TON and source_NPI to help SMSC understand the contents of this sender field.
The rest of your parameters and methods seem fine.
Related
I've class which has a set of attributes.
I'm trying to call WebService from custom Billing device (based on proprietary HW/SW). The problem is that in the application in some cases the required field (an integer in this case) is sent as null. WebService just rejects that.
Is there any way to log such errors in the Server as "return false" prompts the App to resend again (which will fail as the value is still null). Idea is to write to database the errors (with device details and the actual error, integer column is null in this case) and the Application/Web Admin can get in touch with user of the device to take appropriate action.
For debugging, you can use Fiddler2 easily to capture any web traffic, including the full xml of a SOAP request/response (and it even handles SSL easily, unlike Wireshark)
For logging... I wish I knew. Sorry.
Also, dupe of In C#, How to look at the actual SOAP request/response in C#
I've been working on a LoNet mini GSM module (SIM800L), interfacing it with Arduino.
I've inserted the SIM mobile card with Internet connection available.
Through serial monitor I'm communicating with it with no problems, but when it comes to make a GET or a POST request to a webserver page it returns Network Error (601).
Here it is:
AT+SAPBR=3,1,"CONTYPE","GPRS"
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","http://:8080/folder/savedata.php"
OK
AT+HTTPACTION=0
OK
+HTTPACTION: 0,601,0 //601: Network Error
AT+HTTPREAD=1,100000
OK
And no response of the "echo" of the php page...
Do you have any suggestion?
Thanks in advance.
enter image description here
enter image description here
Did you set up your PDP context already? I think some main concepts are that you need to successfully attach and startup GPRS connection.
Some things that need to be active before this will work:
1) Network registration
AT+CREG? should return 0,1 if so, skip to 2)
if it doesn't then you can start by turning on and off the modem by inputting AT+CFUN=0 and then AT+CFUN=1
if you are still having problems registering make sure you have selected the correct network:
AT+COPS? should see your service providers name in the results
eg.
AT+COPS: 1,0,"T-Mobile USA"
If you don't, then make sure your band is set properly to your service provider. Look up your providers 2G band
e.g. t-mobile uses PCS_MODE for their 2G service. set this via:
AT+CBAND="PCS_MODE"
Also, obviously you should make sure you have signal:
AT+CSQ should return at at least a 5 or 6
2) Network Activation
AT+CIPSHUT
AT+CGATT=1 - this can take some time to get through. I have a 40 sec timeout
Its important for this step to work. If it doesn't perhaps restart your modem. But this is a key part.
3) setting PDP context and bringing up GPRS service
AT+SAPBR=3,1,"CONTYPE","GPRS"
set your APN: find out what your 2g APN is from your provider.
e.g. for t-mobile: epc.tmobile.com
define your APN:
T+SAPBR=3,1,"APN","epc.tmobile.com"
AT+SAPBR=1,1 This is the most important part to get through. Sometimes it takes a while to get through, I have a timeout on this part for 3 minutes to let it work.
if this doesn't give you an error proceed:
4) sending HTTP
Basically proceed with what you have...
an example of what I do:
AT+HTTPTERM
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","www.google.com"
AT+HTTPACTION = 0 This should return 200 if it is successful
5 shut down GPRS
AT+CIPSHUT this may give you an error buts its not important
AT+SAPBR=0,1 can take awhile
AT+CGATT=0 also can take a while
anyways I wrote some pretty neat lightweight code for arduino to send data via HTTP. I also wrote one for SMS. let me if you want to take a look. I use a SIM800L -- one of the cheap breakout boards.
If you want to use https add ssl in following order.
mySerial.println("AT+HTTPINIT");
mySerial.println("AT+HTTPSSL=1");
mySerial.println("AT+HTTPPARA=CID,1");
AT+HTTPSSL=1 this will let you to use url with https://
This really useful, if you want to use google cloud functions to add data to firebase.
Try using ipaddress in place of DNS as:
AT+HTTPPARA="URL","http://example.com:8080/folder/savedata.php" OK
Replace it to:
AT+HTTPPARA="URL","http://29.09.07.12:8080/folder/savedata.php" OK
It works in most of the cases.
I'm making an API call from one app to another. I handle authorization by passing an md5ed shared secret + timestamp...
$token = md5( $secret . time() );
Then at the API endpoint, I check the authenticity of the request like this...
if ( md5($shared_secret . time() ) == $token )
...do stuff
This works. But it isn't as reliable as I'd like. I suspect the reason is due to latency in the network (or my slow localhost server) causing the timestamps to be mismatched by a second or so.
I worked around this in a lazy way by dropping the last digit of the timestamp, thus creating up to a 10 second window for my slowpoke server to make the call. However, I'm not satisfied with this because if the call happens to fall at the very end of the 9th second, I'll have the same problem again (send at #######49 != received at ########50).
There must be a better way to do this. What is it?
Consider using token = time || MAC(time, shared_secret) where || is concatenation and MAC is a Message Authentication Algorithm such as HMAC, that takes a secret key and some data and produces an authentication tag. On the server end, check the MAC is valid and the time (received in plaintext) is within an acceptable window.
This is more secure than your current solution (md5 makes a poor MAC) and also solves your window problem.
Note that this scheme is susceptible to replay attacks within the error window that you allow (e.g. the same token could be sent ten times in a one second window, and the server has no way of telling).
Use a nonce instead? Save the nonce to a DB or some persistent storage to make sure the same one isn't used.
Conversely to your '9th second problem' you have a similar problem for seconds ###...0 to ###...9 hashing to the same value when you cut off the trailing 0 through 9. It would allow replay in that 10 second time frame.
Seems like that would be more of a problem for guaranteeing/checking authenticity.
You'd have to send the plaintext and hashed text together for the server to check it but that seems a little better than the time stamp method.
Either way, with those two parameters alone you're only checking that it's not a duplicate request as opposed to authenticating anything.
Using a timestamp is not the correct way because the time is not reliable across systems. Perhaps you can use the length/hash of the message as a parameter instead. It does not, unfortunately, prevent playback from an attacker.
Correct me if I'm wrong, but it seems as though you're dealing with authentication (ie, the sender is who they say they are) rather than authorization. I would suggest that you use SSL/TLS to secure the transmission to know whether or not the transmission is being proxied.
Some of my NServiceBus commands will need to track who issued the command and when. I'm very unsure as to the recommended way to implement this:
Should I create a base class MessageBase, add public Dictionary<string, string> Headers;, and implement IMutateOutgoingMessages?
Should it be added to the MessageContext? If so, how do I ensure the Bus adds it before every message (which needs the headers) is sent?
Is it already done and I just don't know how to access it? (It looks like the user is in the raw MSMQ message...)
NServiceBus already gives you the time the message was sent using the "NServiceBus.TimeSent" header.
Use the builtin NServiceBus headers dictionary and skip the MessageBase
Attaching user id is best done in a outgoing message mutator. Just grab the ID from eg the HttpContext and add it as a header.
http://support.nservicebus.com/customer/portal/articles/860492
To get the time (in your handler/saga):
Bus.CurrentMessageContext.TimeSent
I'm using Netty to write a client application that sends UDP messages to a server. In short I'm using this piece of code to write the stream to the channel:
ChannelFuture future = channel.write(request, remoteInetSocketAddress);
future.awaitUninterruptibly(timeout);
if(!future.isDone()){
//abort logic
}
Everything works fine, but one thing: I'm unable to test the abort logic as I cannot make the write to fail - i.e. even if the server is down the future would be completed successfully. The write operation usually takes about 1 ms so setting very little timeout doesn't help too much.
I know the preffered way would be to use an asynch model instead of await() call, however for my scenario I need it to be synchronous and I need to be sure it get finnished at some point.
Does anyone know how could I simulate an uncompleted future?
Many thanks in advance!
MM
Depending on how your code is written you could use a mock framework such as mockito. If that is not possible, you can also use a "connected" UDP socket, i.e. a datagram socket that is bound to a local address. If you send to a bogus server you should get PortunreachableException or something similar.
Netty has a class FailedFuture that can be used for the purpose of this,
You can for example mock your class with tests that simulate the following:
ChannelFuture future;
if(ALWAYS_FAIL) {
future = channel.newFailedFuture(new Exception("I failed"));
else
future = channel.write(request, remoteInetSocketAddress);