none
Unable to download Image from specific link RRS feed

  • Question

  • Hello Everyone,

    I am working on a project that requires me to download images from a tile map and display them for the user to view. The map is meant to be used to display coordinates from another device. The code that I've been using is below and I am unable to get the image from the site.

                    HttpWebRequest ULWR = (HttpWebRequest)HttpWebRequest.Create(ULString);
                    ULWR.AllowWriteStreamBuffering = true;
                    ULWR.Timeout = 3000;
    
                    WebResponse webResponse = ULWR.GetResponse();
                    Stream St = webResponse.GetResponseStream();
                    Image I = Image.FromStream(St);

    The "ULString" that can be tested is: https://tile.openstreetmap.org/7/33/48.png

    If I run the code using the tie coordinates given, I receive the error:

    System.Net.WebException: 'Unable to connect to the remote server'

    Inner Exception:
    SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 140.211.167.105:443

    Thanks in advance for any responses and let me know if there are any questions.


    Sincerely, Nathaniel Hastings


    • Edited by NHastings2 Wednesday, March 13, 2019 5:38 PM
    Wednesday, March 13, 2019 5:36 PM

Answers

  • I just tried your code:

    private void button1_Click(object sender, EventArgs e)
    {
        string ULString = "https://tile.openstreetmap.org/7/33/48.png";
    
        HttpWebRequest ULWR = (HttpWebRequest)HttpWebRequest.Create(ULString);
        ULWR.AllowWriteStreamBuffering = true;
        ULWR.Timeout = 3000;
    
        WebResponse webResponse = ULWR.GetResponse();
        Stream St = webResponse.GetResponseStream();
        Image I = Image.FromStream(St);
    
        pictureBox1.Image = I;
    }
    

    And it worked perfectly well:

    Screenshot

    I suspect that there may be a problem with your DNS resolution. I did a NSLOOKUP for tile.openstreetmap.org and the returned address was 185.73.44.30, not 140.211.167.105.

    Wednesday, March 13, 2019 7:09 PM
    Moderator

All replies

  • I just tried your code:

    private void button1_Click(object sender, EventArgs e)
    {
        string ULString = "https://tile.openstreetmap.org/7/33/48.png";
    
        HttpWebRequest ULWR = (HttpWebRequest)HttpWebRequest.Create(ULString);
        ULWR.AllowWriteStreamBuffering = true;
        ULWR.Timeout = 3000;
    
        WebResponse webResponse = ULWR.GetResponse();
        Stream St = webResponse.GetResponseStream();
        Image I = Image.FromStream(St);
    
        pictureBox1.Image = I;
    }
    

    And it worked perfectly well:

    Screenshot

    I suspect that there may be a problem with your DNS resolution. I did a NSLOOKUP for tile.openstreetmap.org and the returned address was 185.73.44.30, not 140.211.167.105.

    Wednesday, March 13, 2019 7:09 PM
    Moderator
  • Thanks for your response Alberto,

    I found out that the program files itself were corrupt and that's why it couldn't connect. I redid the project in a new solution and it worked fine. Thank you again for your response and your answer will be marked as the Answer.


    Sincerely, Nathaniel Hastings

    Thursday, March 14, 2019 3:00 PM