Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

 

My windows service is capable of connecting to a third party service provider, http://www.clickatell.com in this case. I am using the third party to send out a number of sms text messages in the event that another service goes down or fails to reply within a specific timeframe. I am using a List<string> to store the list of number that I am sending to, and passing my message as a string.

 

The problem that I am having is that when I go to send the last message, I get a timeout exception. I have tried to get the service to sleep for 15 seconds before sending each message, but this has had no effect.

 

Here is the code that I am using:

       //Queue the message to the EMS personnel, and send it.
       private static void QueueEMSMessages(ClubtextMonitor.Modules.MonitorConnect myConnection, String sysMessage)
       {
           //Get the person who is to receive the message.
           List<string> msgDestination = myConnection.GetTechSupport();

          //Create the message and send it to the support person.
           foreach (string ems in msgDestination)
           {
               try
               {
                   ClubtextMonitor.Modules.Message errMessage = new ClubtextMonitor.Modules.Message(sysMessage, ems);
                   //Wait for 15 seconds before sending the message
                   System.Threading.Thread.Sleep(15000);
                   errMessage.sendMessage();
               }
               catch (Exception ex)
               {
               }
           }
       }

//Allow the client to send the message for the user.
       public bool sendMessage()
       {
           //Parameter for storing the send message credentails
           string[] credentials;

           //Get the credentials necessary for sending the message.
           ClubtextMonitor.Modules.MonitorConnect connection = new ClubtextMonitor.Modules.MonitorConnect();
           credentials = connection.GetCredentials();

           bool outputValue = false;

           //Ensure that the correct number of credentials have been supplied.
           if (3 == credentials.Length)
           {
               outputValue = true;
               WebRequest objRequest;

               //The web request to be sent to the message gateway.
               string msgRequest;
               msgRequest = "http://api.clickatell.com/http/sendmsg?user=" + credentials[1].ToString() +
                                   "&password=" + credentials[2].ToString() + "&api_id=" + 
                                       credentials[0].ToString() +"&to=" + msgDestination 
                                           + "&text=" + msgText;

               //Send the message to the individual on tech. support.
               objRequest = System.Net.HttpWebRequest.Create(msgRequest);
               objRequest.GetResponse();
           }
           else
           {
               outputValue = false;
           }
           
           return outputValue;
       }

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

  • Administrators
Posted
Not a clue if this will help but you are creating a response object for each call of the sendMessage method that you are never using - if you try either calling response.Close() before exiting the method or just not creating the response does that fix the problem?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Thanks for the reply PlausiblyDamp, I should have mentioned that my two methods are located in two different objects so I need to createa response object. Based on what you are saying, I should locate this line to outside the foreach loop and only create one object instead of three. I will also try the response.Close() option.

 

Again many thanks.

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...