Skip to content

How to use internet proxy with messages sdk #22

@drelephant

Description

@drelephant

We're running in a corporate network behind a proxy.

I'm trying to test the messagemedia API.

Using the first example for sending an SMS, I get the following:

failure
com.messagemedia.messages.exceptions.APIException: Failed to connect to api.messagemedia.com/54.153.174.199:443`

I tried adding these lines to the example (ip's/port redacted) :

System.setProperty("http.proxyHost", "xx.xx.xx.xxx");
System.setProperty("http.proxyPort", "xxxx");
System.setProperty("https.proxyHost", "xx.xx.xx.xxx");
System.setProperty("https.proxyPort", "xxxx");

, which worked for the following example to show an https page

package org.example;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class testNetworkConnection {
    public static void main(String args[]) {
        System.setProperty("http.proxyHost", "xx.xx.xx.xxx");
        System.setProperty("http.proxyPort", "xxxx");
        System.setProperty("https.proxyHost", "xx.xx.xx.xxx");
        System.setProperty("https.proxyPort", "xxxx");
        try {
            download("https://www.google.com");
        } catch (IOException e) {
            System.out.println(e);
        }
    }
    public static void download(String urlString) throws IOException {
        URL url = new URL(urlString);
        try(
                BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
        ) {
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
        }
    }
}

, but it still gives the same error.

I'm not 100% sure our proxy isn't blocking the connection, but I think it isn't?

Any ideas on how to get it to connect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions