Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My code is running perfectly well when I run my project through Visual Studio 2010.But when I configure the application on IIS 5 the code gives following exception:

Unable to connect to the remote server.

at System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data)
at System.Net.WebClient.UploadValues(String address, String method, NameValueCollection data)
at _Default.RunCrawler(String source, String keyword, String fileType)

System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 111.111.222.19:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception).

Code
WebClient webclient = new WebClient();
byte[] responseArray = webclient.UploadValues("some source URL", "POST", values);
response = System.Text.Encoding.ASCII.GetString(responseArray);
Posted
Comments
Kareem Abou Saad 18-Jun-14 4:42am    
Usually this error is due to some firewall settings that are blocking the process of connecting to the server ...
ZurdoDev 18-Jun-14 7:39am    
I agree with Kareem. When you know the code works but is not working under a certain scenario it is likely permissions somehow, in this case possibly a firewall blocking it.

1 solution

when I tried to run the code on another server machine, the source URL returns data as special characters as :

XML
�      �`I�%&/m�{J�J��t��`$ؐ@������iG#)�*��eVe]f@�흼��{���{���;�N'���?\fdl��J�ɞ!���?~|?"��Ey��w�������~R��~2����>y��W��w����g������W/���/���==���O����b���Ý컻�W�^�'���y���yq��N�S��ӽ�O�xsqe����e39}��'���S������_T/��r��|����O����P��>z<ϳ���X�M�u~��G�]=�{w57�V����6�.��2o�~��;��b��㬙��=��^M�<y��f����gO����������}v���ӓ�{'�N|z����Gi{��?���ߵw�M�QZ��g5�u�7�<o?J�=n��̏~b��m^���iV/��E����<k���]i�x��Y
���_�..?��Z����~C�|�N�/��q�N�Y���g_�y�}��5ӺX�i�-/��a���2{�~�6��Re�ϊ�O���?/hw��*�^��$+��n��U�,ލ���9�7NR}��%���o�<�+�o���7N.�:]�WW�rV]����z9m�j�N���Z�W[뺼�'��7N~�6�L~��U�������"�x��</.��g�;;��b��?�w��;�NJ�tK�:����N��-8�d��/���_���,ԛ��d�M˂&���.����O�㻻�٫17��
��9���e�j�Zp:U>s���|��/|Oi�ib�F���3�^N�?��{S�͗�g�Ǔ����{��N&����O�>�����=��0������&;�'�3R
�&��^�p6;�L'{�?>�m�����?9y��|��iI~���j�l  ���zz!d��'�����p����u1�_�U}}�����,!�`�n�T�����EV_��>�!�V+�/�Ud����A=��iV���6��y:��Y^�K����{�u�\e�
�����*����vM�����iUV�������mTQ�9���}E�}X��R���n�X^�
M��ߐZ��UI��#��.�r��Я���ң��U]���t^����ik�Uh�da�����",�Cϧ�~�^*#S�bq(�����d˷��w����»�f�8��ؙx۲�.Q�0��}(���l ťƛ]Ԩ72Me�4�}$�4����jN�t߄Hg }5~=N���鷫E��nv��E��6����<��T4@��}Eq�+��y�{����bv6�����Ϗ���^����W�O_�����ً������ˏ�N�$��N_��e1}O����^��������*��j��[O~�E���?]��
uONN6mӯ��X~-�i�����Y=��X�|>7�~h'ntS�4�SG#|s�����龜c|�~���:��,���Bϫz�f�h
�%d2�B)���j��G+�|��H+@�(-f�O���� �
���/��JT��w�2���Š_O9ddck_M�x���P�袘���}��A������7����k�����{Q&���w���4fu�?l��r���1�ά I*���_M��vo�Ի2_^0�������s�W�h�(�Cu���_�=|�v�Q�v��6㿑�7Ҹ?t#s��|d=��܎IE/�v�����դ]��F����E��N��%�#(�;�ca��#�=��.K���]��}!ݕٮL��O �pȣ:��IZ-d&�Uw���@�>}Jq���/����n!�6���w?�yNӧ�N��!�Vn���r.����<�[
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900