无法连接到端口8080:连接被拒绝错误编号:7(cURL)

编程入门 行业动态 更新时间:2024-10-26 10:40:06
本文介绍了无法连接到端口8080:连接被拒绝错误编号:7(cURL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下代码-

$ url ='52.77.156.123:8080/LebuPay/check -付款'; $ ch = curl_init($ url); $ data = array( successURL =>'jsonviewer.stack.hu', failureURL =>'http:// jsonviewer.stack.hu',金额 => $ a $, orderTransactionID => $ order_id,名字 =>, lastName =>, email =>, mobileNumber =>, accessKey => some_random_key ); $ jsonEncode = json_encode($ data); curl_setopt($ ch,CURLOPT_POST,TRUE); curl_setopt($ ch,CURLOPT_POSTFIELDS,$ jsonEncode); curl_setopt($ ch,CURLOPT_RETURNTRANSFER,TRUE); curl_setopt($ ch,CURLOPT_HEADER,TRUE); curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ ch,CURLOPT_HTTPHEADER,array(’Content-Type:application / json’)); $ result = curl_exec($ ch); $ result = json_decode($ result,true); echo错误CURL:。 curl_error($ ch)。 \n错误编号:。 curl_errno($ ch); curl_close($ ch); $ token = $ result ['token']; 标头(位置:52.77.156.123:8080/LebuPay/execute-payment?token=$token);

该代码在我的本地主机上有效,但是当我将其上传到服务器(Godaddy linux)上时。它给我错误无法连接到52.77.156.123端口8080:连接被拒绝,错误号:7

我尝试从中获取响应的API托管在AWS。

有什么办法可以解决这个问题吗?谢谢。

解决方案

由于更换服务器时会发生问题,因此我怀疑问题是出站服务器阻塞了端口。 / p>

这是一个很老的论坛帖子说:

我不知道它是否适用于其他任何内容而不是共享主机,但Godaddy共享主机具有除80外的所有传出端口,这些端口都被防火墙阻止了

问题在于,Godaddy共享主机不允许您从您的站点发出除80外的任何端口的请求。

这就像有一所房子,除了前门外,所有的门窗都焊接在一起。

并且

与Godaddy支持人员联系,并被告知端口80 80即使在其专用服务器上也被阻止。

在此期间,这可能已经改变了,但是由于您遇到了问题,我不知道

可能的解决方案:

  • 不要使用糟糕的托管服务(Godaddy的声誉很差)
  • 以某种方式说服Godaddy开放港口
  • 找到一个可以让您使用端口80将请求发送到Godaddy网络之外的代理

I have the following code -

$url = '52.77.156.123:8080/LebuPay/check-payment'; $ch = curl_init($url); $data = array( "successURL" => 'jsonviewer.stack.hu', "failureURL" => 'jsonviewer.stack.hu', "amount" => $amount, "orderTransactionID" => $order_id, "firstName" => "", "lastName" => "", "email" => "", "mobileNumber" => "", "accessKey" => "some_random_key" ); $jsonEncode = json_encode($data); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonEncode); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $result = curl_exec($ch); $result = json_decode($result, true); echo "Error CURL: " . curl_error($ch) . " \nError number: " . curl_errno($ch); curl_close($ch); $token = $result['token']; header("location: 52.77.156.123:8080/LebuPay/execute-payment?token=$token");

The code works on my localhost but when I upload it on the server (Godaddy linux). It gives me error "Failed to connect to 52.77.156.123 port 8080: Connection refused Error number: 7"

The API I'm trying to get response from is hosted on AWS.

Any idea how I can solve this problem? Thanks.

解决方案

Since the problem occurs when you changed the server, I would suspect that the problem is the outgoing server blocking the port.

This, admittedly old, forum post says:

I don't know if it applies to anything other than shared hosting, but Godaddy shared hosting has all outgoing ports other than 80 blocked by their firewall

and

The problem is that Godaddy shared hosting will not let you make requests from your site that go to any port other than 80.

It's like having a house where all of the doors and windows, except the front door, are welded shut.

and

Talked to Godaddy Support and was told port 8080 is blocked, even on their dedicated servers.

This might have changed in the meantime, but since you are experiencing the problem I don't think it has.

Possible solutions:

  • Don't use awful hosting (Godaddy has a terrible reputation)
  • Somehow persuade Godaddy to open up the port
  • Find a proxy that lets you use port 80 to get the request outside of Godaddy's network

更多推荐

无法连接到端口8080:连接被拒绝错误编号:7(cURL)

本文发布于:2023-06-05 01:13:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/508815.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   端口   被拒   编号   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!