dikhan/pagerduty-client

Proxy Support

asyd opened this issue · 3 comments

asyd commented

Hello,

I'm not sure if it's the right place where to fill the issue but let's go..

I setup the Jenkins PagerDuty plugin where Jenkins is running behind a proxy.

Jenkins is started with the following JVM args:

java -Dhttp.proxyHost=xxx -Dhttp.proxyPort=8080 -Dhttps.proxyHost=xxxx -Dhttps.proxyPort=xxx

But when the job trigger the pagerduty plugin, which use the current library, I have the following exception:

events.pagerduty.com/54.245.165.68] failed: Connection refused (Connection refused)
	at com.github.dikhan.HttpApiServiceImpl.notifyEvent(HttpApiServiceImpl.java:52)
	at com.github.dikhan.PagerDutyEventsClient.trigger(PagerDutyEventsClient.java:78)
	at org.jenkinsci.plugins.pagerduty.util.PagerDutyUtils.triggerPagerDuty(PagerDutyUtils.java:106)
	at org.jenkinsci.plugins.pagerduty.PagerDutyTrigger.perform(PagerDutyTrigger.java:217)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
	at hudson.model.Build$BuildExecution.post2(Build.java:186)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
	at hudson.model.Run.execute(Run.java:1752)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)

So I'm wondering if it's the expected behavior, and if there a way to setup a proxy on this lib

Cheers

Hi Asyd,

Thanks for raising the ticket.

As far as I can tell from the stack trace, this does not seem to be an issue with the PagerDutyEvents library but rather something related to the stack (jenkins configuration, network, fw, etc). The error message suggests that something along the way is refusing the connection. These usually happens for the following reasons:

  • Nothing is listening on the IP:Port you are trying to connect to -> based on the stack trace the events.pagerduty.com seems to be resolving to 54.245.165.68...and I just confirmed that pagerduty indeed announces that IP:
➜  ~ host events.pagerduty.com
events.pagerduty.com is an alias for events.gslb.pagerduty.com.
events.gslb.pagerduty.com has address 104.42.227.51
events.gslb.pagerduty.com has address 54.245.165.68
events.gslb.pagerduty.com has address 13.56.226.208
events.gslb.pagerduty.com has address 54.203.47.92
events.gslb.pagerduty.com has address 52.53.154.170
  • The port is blocked by a firewall -> is your Jenkins instance configured to talk to the internet? looks like something is blocking the connection..

I just did a sanity check to verify that PagerDutyEvents v2.0.2 - version used in the Jenkins PagerDuty plugin is working, and the tests was successful - I was able to trigger an incident and get the event result back.

Few questions that might help narrowing down the issue:

  • Have you tried telneting (netcat, etc) to 'events.pagerduty.com' from Jenkins box?
➜  ~ telnet events.pagerduty.com 443
Trying 54.245.165.68...
Connected to events.gslb.pagerduty.com.

Hope this helps

asyd commented

Hi @dikhan thanks for the feedback.

Indeed I can't reach Internet directly from my Jenkins server, that why I configured a proxy, in Jenkins itself as well as the JVM using httpProxy/httpsProxy args (as you can see in the initial report) but pagerduty-clients seems ignore these arguments.

Hi Asyd,

Makes sense, the http client used internally is pointing directly to upstream (and client has to have connectivity to the internet) so proxy is not supported at the moment. I would be happy to review the changes if you would like to submit a Pull request. One place I would recommend you to look at is the HttpApiServiceImpl, looks like unirest http client supports a proxy:

	/**
	 * Set a proxy
	 */
	public static void setProxy(HttpHost proxy) {
		Options.setOption(Option.PROXY, proxy);

		// Reload the client implementations
		Options.refresh();
	}

Since this is not an actual bug but a feature request, I will go ahead and close this ticket.

Let me know if you have any further questions.

Thanks,
Dani