I am getting the following error when I am sending an SMS through http webrequest from my service :
system.net.webexception:the remote server returned an error 417 expectation failed. we are using proxyserver.
I have tried changing the machine.config with the following settings, still no success.
RamsPosted Aug 10, 2011, 5:12 AM
"system.net.webexception:the remote server returned an error 417 expectation failed
at MBS.SmsMgr.SendSMS(Object stringPost)
at MBS.Dispatcher.CommonProcedures.SendSMS(CommonProcedures objparams)".
Please do find the code below :
Public Function SendSMS(ByVal stringPost As System.Object) As String Implements ISmsMgr.sendSMSDim strReturnValue As String = String.EmptyDim objWebRequest As HttpWebRequest = Nothing
Dim objWebResponse As HttpWebResponse = Nothing
Dim objStreamWriter As StreamWriter = Nothing
Dim objStreamReader As StreamReader = Nothing
Try
Dim strProxyURL As String = String.EmptyDim iProxyPort As Integer = 0If Not ConfigurationManager.AppSettings.Item("ProxyURL") Is Nothing ThenstrProxyURL = ConfigurationManager.AppSettings.Item(
"ProxyURL").ToString.TrimEnd If
If Not ConfigurationManager.AppSettings.Item("ProxyPort") Is Nothing TheniProxyPort =
CInt(ConfigurationManager.AppSettings.Item("ProxyPort").ToString.Trim)End If
Dim strSMSDialerConnectionName As String = ConfigurationManager.AppSettings("SMSDialerConnectionName")Dim iAvailConType As Integer = DetectConnection()If iAvailConType = enmConnectionType.NOTCONNECTED Then ' If not connected,
'Then detect the Modem connection and Dialp up.
If Not String.IsNullOrEmpty(strSMSDialerConnectionName) Then
Dim chSplit() As Char = {";"}Dim strDialeConnections() As String = strSMSDialerConnectionName.Split(chSplit)If strDialeConnections.Length > 0 Then
For i = 0 To strDialeConnections.Length - 1If DialupConnection(strDialeConnections(i)) TheniAvailConType = enmConnectionType.MODEM
strProxyURL =
iProxyPort = 0
String.EmptyIf Not ConfigurationManager.AppSettings.Item("DailUpProxyURL") Is Nothing ThenstrProxyURL = ConfigurationManager.AppSettings.Item(
"DailUpProxyURL").ToString.TrimEnd If
If Not ConfigurationManager.AppSettings.Item("DailUpProxyPort") Is Nothing TheniProxyPort =
CInt(ConfigurationManager.AppSettings.Item("DailUpProxyPort").ToString.Trim)End If
Exit For
End If
Next
End If
End If
End If
If iAvailConType <> enmConnectionType.NOTCONNECTED ThenobjWebRequest =
Dim bytesToSend As Byte() = Encoding.UTF8.GetBytes(stringPost)Dim strSMSApi As String = ConfigurationManager.AppSettings.Item("SMSApi").ToStringDirectCast(WebRequest.Create((strSMSApi & "?") + stringPost.ToString()), HttpWebRequest)'add eventvwr : laxmanEventLog.WriteEntry(
"SENDSMS.strSMSApi ", (strSMSApi & "?") + stringPost.ToString())'(strSMSApi & "?") + stringPost.ToString()objWebRequest.Method =
"POST"
If (Not String.IsNullOrEmpty(strProxyURL.Trim)) ThenobjProxy =
objProxy.Credentials = CredentialCache.DefaultNetworkCredentials
objWebRequest.Proxy = objProxy
New WebProxy(strProxyURL, iProxyPort)End IfobjWebRequest.ContentLength = bytesToSend.Length
objWebRequest.ContentType =
"application/x-www-form-urlencoded"objStreamWriter =
objStreamWriter.Write(stringPost)
objStreamWriter.Flush()
objStreamWriter.Close()
objWebResponse =
objStreamReader =
strReturnValue = objStreamReader.ReadToEnd()
objStreamReader.Close()
New StreamWriter(objWebRequest.GetRequestStream())DirectCast(objWebRequest.GetResponse(), HttpWebResponse)New StreamReader(objWebResponse.GetResponseStream())Priya LingePosted Aug 8, 2011, 7:46 AM
Please see below link.
http://code.google.com/p/duplicati/issues/detail?id=378.
Hope it will help you to solve the error.
Thanks.
RamsPosted Aug 8, 2011, 7:40 AM
Thanks for the reply.. we tested the same service in our network..it is showing succesfull..but the client is using a proxy server which i think is creating a problem..
Zoran HorvatPosted Aug 8, 2011, 7:31 AM
Give us precise Expect value you're sending.
Zoran