MMS php script post issue

MMS php script post issue SearchSearch
Author Message
Timothy DeDecker
New member
Username: Griffle

Post Number: 1
Registered: 11-2010
Posted on Wednesday, January 26, 2011 - 06:45 pm:   

I am using nowsms and php to send sms and mms messages. the script for sms works perfectly.
but for the scripts that you provide to do mms hang up on the post and take down my entire site using all the apache resources. Also when it does go through the first image no matter what image it is never goes through to the phone. and any image after that is fine. only have this issue with images.

Would appreciate any help.

Thanks,
Tim
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2854
Registered: 08-2008
Posted on Wednesday, January 26, 2011 - 09:45 pm:   

Hi Tim,

Maybe it's a PHP version issue? (I don't know enough about PHP to know if there are any version issues, but I will ask what version of PHP you are running so that I can verify that the script works ok with that version of PHP.)

Or maybe you have extremely limited memory available in a shared hosting situation?

Any MMS content is read into memory by the PHP script as an HTTP POST submission is built.

I'd suggest trying with extremely small images to try to determine if it is a memory issue with the hosting configuration.

Also ... you say that if you can send it, it never goes through to the phone. Please confirm that you can send correctly using the web form first, before troubleshooting any scripts.

--
Des
NowSMS Support
Timothy DeDecker
New member
Username: Griffle

Post Number: 2
Registered: 11-2010
Posted on Wednesday, February 02, 2011 - 10:58 pm:   

http://realtygo.digitaldogs.com/info/ is our development environment that I am building this script on. I created a script for you to see all the server information. I have upped the memory limit and the server has the same effect. It does send the message but timeout the script. Also in the message the very first image does not show. but It will show any other image after it.

I have also tried with very small images no change.

We are running the NOWSMS server on windows 7 64bit.

Based on my testing I am confident that its not a memory issue.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2884
Registered: 08-2008
Posted on Friday, February 04, 2011 - 10:07 pm:   

Hi Timothy,

Sorry for the delay in response. I'm trying to think of what the best way would be to troubleshoot this.

It sounds like there might be a line break or boundary marker missing in the output generated by the script.

That would explain why the script might hang on a single image submission ... or why the first image might be missing on a multiple image submission.

Have you ever used WireShark before? (www.wireshark.org)

I'd like to see a trace of some output from your script that is destined for NowSMS to get a better idea of what is actually happening. That's probably the best way to actually figure out what is happening.

--
Des
NowSMS Support
Timothy DeDecker
New member
Username: Griffle

Post Number: 3
Registered: 11-2010
Posted on Tuesday, February 08, 2011 - 08:59 pm:   

Thank you very much for your help.

I dont have the ability to use wireshark on the computer this is run under. But i can provide the output into a file.
http://realtygo.digitaldogs.com/mms-text.txt
just replace the fsocket to a fopen.

Thanks,
Tim
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2889
Registered: 08-2008
Posted on Tuesday, February 08, 2011 - 10:17 pm:   

Hi Tim,

Can you reupload with a different file extension (or put it in a ZIP or RAR and upload). I think our web server does some character translations on files with a "TXT" extension. Probably just CR to CRLF translations, but I'm not sure.

Your file looked fine, I just had to modify the "Content-Length:" header to submit ... and the JPEG data was garbled. But those two problems are most likely due to the "TXT" file extension and the web server performing some conversions.

The basic structure looked correct, but I'd like to try a live test to see if there's some other problem area that I'm missing. So if you could reupload, I'll check that out.

Also, a sanity check question. You are able to send this same message ok using our web form, right? I just want to make sure we're troubleshooting this in the right direction ... so please verify that sending the same content via the web interface works, so we know we are dealing with a PHP script specific issue.

--
Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2890
Registered: 08-2008
Posted on Tuesday, February 08, 2011 - 10:18 pm:   

Another thought ... I understand that you can't run WireShark on your web server, but can you run it on the PC running NowSMS to capture what NowSMS is seeing?
Timothy DeDecker
New member
Username: Griffle

Post Number: 4
Registered: 11-2010
Posted on Thursday, February 10, 2011 - 05:31 pm:   

here is the capture from running wireshark on the sms server. Sorry it took so long to get back to you.
application/octet-streamwireshark output
realtygo message send capture.pcap (288.7 k)
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2895
Registered: 08-2008
Posted on Thursday, February 10, 2011 - 06:58 pm:   

Thanks Tim.

I should have tried the script myself and I would noticed the problem more quickly.

There are two problems.

1.) The script is calculating the "Content-Length:" header incorrectly. A quick work-around for this problem is to change $dc = 0 to $dc = 27. Otherwise, the last object will be truncated. (I don't think that the text "This is a MIME Message" was present in the original version of this script. The calculation of the content-length is not including this string and the CRLF pair that follows it.)

2.) The script hanging problem is a bit more complex, but there is a quick work-around. Change HTTP/1.1 to HTTP/1.0. Late last year we added HTTP keep-alive socket performance to improve performance. This PHP script claims to be using HTTP/1.1, but it doesn't actually understand keep-alive sockets, so it is waiting until the server closes the connection for the script to complete.

--
Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2896
Registered: 08-2008
Posted on Thursday, February 10, 2011 - 07:19 pm:   

One additional note ... I don't believe this note applies to you, but it may apply to others that experience a similar problem.

Some environments may experience a problem where the last object of an MMS message is missing or truncated when sending through the sendmms.php script.

This can happen if mbstring.func_overload is defined in your PHP configuration.

In order of this script to function correctly in those environments, it is necessary to modify the script to use the mb_strlen function instead of strlen.

A modified version of the script that uses mb_strlen can be found at http://www.nowsms.com/download/sendmms2-php.txt.