2016-10-26 35 views
0

我正在上laravel一個小網站工作,我取回從符的一些數據,並用它在我的本地和一切都很好,然後我上傳它在我的服務器3和他們都不能發送請求。嫋嫋不工作的服務器,但在localhost

服務器1 = http://testing2.vire-news.com/(主持人:GoDaddy的)

服務器2 = http://testing.asmani.pk/(主機:HostGator的)

,如果你點擊搜索它不會給你的web服務的結果。

我已搜查計算器上把一切都挺CURLOPT_POSTCURLOPT_FOLLOWLOCATION等,並沒有什麼作品出來

服務器1上提示錯誤

「無法連接到emexonline.com 3000端口:連接拒絕「

在服務器2上它保持連接,然後超時。 我做了一個相同代碼的簡單php文件來測試出laravel環境,它也不起作用。

注意:我已經測試了其他類似facebook和twitter API的捲髮web服務,並且它們都在這些服務器上正常工作,並且我已聯繫web服務提供商,他們說一切正常,其他客戶也在使用他們的web服務沒有任何問題。

這裏是我已經取下來從XML數據的用戶名和密碼的代碼。 一切工作正常在本地和服務器上它給錯誤和所有其他功能工作正常只有Web服務沒有連接。

$xml_data = '<?xml version="1.0" encoding="utf-8"?> 
     <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
      <soap12:Body> 
      <SearchPart xmlns="http://emexonline.com:3000/MaximaWS/"> 
       <Customer> 
       <UserName>username</UserName> 
       <Password>password</Password> 
       <SubCustomerId>0</SubCustomerId> 
       <CustomerId>20879</CustomerId> 
       </Customer> 
       <DetailNum>'.$Request->search.'</DetailNum> 
       <ShowSubsts>0</ShowSubsts> 
      </SearchPart> 
      </soap12:Body> 
     </soap12:Envelope> 
     '; 
     $headers = array(
     "POST /MaximaWS/Service.asmx HTTP/1.1", 
     "Host: emexonline.com", 
     "Content-Type: application/soap+xml; charset=utf-8", 
     "SOAPAction: \"http://dpd.com/common/service/LoginService/2.0/getAuth\"", 
     "Content-Length: ".strlen($xml_data) 
     ); 

     $url = 'http://emexonline.com:3000/MaximaWS/Service.asmx'; 
     $curll = curl_init(); 
     curl_setopt($curll, CURLOPT_URL,$url); 
     curl_setopt($curll, CURLOPT_RETURNTRANSFER,1); 
     curl_setopt($curll, CURLOPT_TIMEOUT, 30); 
     curl_setopt($curll, CURLOPT_HTTPHEADER, $headers); 
     curl_setopt($curll, CURLOPT_SSL_VERIFYPEER, FALSE); 
     curl_setopt($curll, CURLOPT_POSTFIELDS, $xml_data); 
     $reply = curl_exec($curll); 

好了,不要問得使用curl_errno($ch)curl_error($ch)curl_getinfo($ch),我已經使用他們,並得到了結果。

這裏的結果和成功的本地主機運行的信息

Array ([url] => http://emexonline.com:3000/MaximaWS/service.wsdl [content_type] => text/html [http_code] => 405 [header_size] => 203 [request_size] => 834 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.578 [namelookup_time] => 0.25 [connect_time] => 0.422 [pretransfer_time] => 0.422 [size_upload] => 617 [size_download] => 1293 [speed_download] => 2237 [speed_upload] => 1067 [download_content_length] => 1293 [upload_content_length] => 617 [starttransfer_time] => 0.578 [redirect_time] => 0 [redirect_url] => [primary_ip] => 86.98.88.87 [certinfo] => Array () [primary_port] => 3000 [local_ip] => 192.168.0.102 [local_port] => 53325) 

error: no error 

這裏的

Array ([url] => http://emexonline.com/MaximaWS/Service.asmx [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 30.001115 [namelookup_time] => 0.12449 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => [certinfo] => Array () [primary_port] => 0 [local_ip] => [local_port] => 0) 

error: Connection timed out after 30001 milliseconds 
+0

是,你是在有問題的服務器上啓用捲曲? – FluxCoder

+0

當您從服務器使用端口進行curl時,當localhost沒有端口並且擊中其他端點時。是否有一個原因?從你的電腦,並從服務器 – krasipenkov

+0

@krasipenkov這是一個錯字都哥哥正在使用相同的代碼嘗試從服務器Telnet到遠程服務器上的3000端口。 –

回答

0

可以增加30至60超時也在你的代碼有結果的和不成功的服務器運行的信息未設置 curl_setopt($ ch,CURLOPT_POST,1)此參數。

+0

網絡訪問。 –

+0

這個問題是我測試我的客戶的服務器上的服務器本身它工作得很好 感謝所有。 curi在PHP ini中啓用,但從linux核心關閉,不允許它通過 –

相關問題