首页 \ 问答 \ cURL和SSL,connect()超时(cURL and SSL, connect() time out)

cURL和SSL,connect()超时(cURL and SSL, connect() time out)

我正在使用cURL连接到SSL服务器来重新发送和发送XML文件,但我一直在努力

“连接()超时!”

当我尝试连接到服务器时。

我是cURL的新手,所以我不知道服务器配置,某些证书或什么是错误的。

我正在尝试运行的代码(由SSL服务器的所有者提供给我):

function post($url, $post)
{
    $ch = curl_init();
    if($ch)
    {
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT,60);
        curl_setopt($ch, CURLOPT_VERBOSE,0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $result = curl_exec($ch);
        echo '<pre>', curl_error($ch);
        curl_close($ch);
        if(!empty($result))
            return $result;
    }
}

cURL版本信息:

[version_number] => 463362
[age] => 3
[features] => 1597
[ssl_version_number] => 0
[version] => 7.18.2
[host] => i486-pc-linux-gnu
[ssl_version] => OpenSSL/0.9.8g
[libz_version] => 1.2.3.3
[protocols] => Array
    (
        [0] => tftp
        [1] => ftp
        [2] => telnet
        [3] => dict
        [4] => ldap
        [5] => ldaps
        [6] => http
        [7] => file
        [8] => https
        [9] => ftps
        [10] => scp
        [11] => sftp
    )

I'm using cURL to connect to a SSL server to recive and send XML-files but I keep getting

"connect() time out!"

when I try to connect to the server.

I'm kind of new to cURL so I don't know if it's something wrong with the servers configuration, some certificate, or what.

The code i'm trying to run (given to me by the owner of the SSL server):

function post($url, $post)
{
    $ch = curl_init();
    if($ch)
    {
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT,60);
        curl_setopt($ch, CURLOPT_VERBOSE,0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $result = curl_exec($ch);
        echo '<pre>', curl_error($ch);
        curl_close($ch);
        if(!empty($result))
            return $result;
    }
}

cURL version information:

[version_number] => 463362
[age] => 3
[features] => 1597
[ssl_version_number] => 0
[version] => 7.18.2
[host] => i486-pc-linux-gnu
[ssl_version] => OpenSSL/0.9.8g
[libz_version] => 1.2.3.3
[protocols] => Array
    (
        [0] => tftp
        [1] => ftp
        [2] => telnet
        [3] => dict
        [4] => ldap
        [5] => ldaps
        [6] => http
        [7] => file
        [8] => https
        [9] => ftps
        [10] => scp
        [11] => sftp
    )

原文:https://stackoverflow.com/questions/9349350
更新时间:2024-01-14 12:01

最满意答案

我认为月份的内部编号从0开始,而不是1.因此,您可能需要在某处添加+1。
编辑:在您显示更多代码之后:所需的更改是

String month = form_helper.round(gcal.get(GregorianCalendar.MONTH) + 1);

I think internal numbering of months starts with 0, not 1. So, you probably need to somewhere add +1.
Edit: after you showed some more code: The needed change is

String month = form_helper.round(gcal.get(GregorianCalendar.MONTH) + 1);

相关问答

更多
  • 恭喜,您已经用JDBC:Date类处理命中了我最喜爱的宠物小便。 基本上,数据库通常至少支持三种日期,时间和时间戳的日期时间字段。 它们中的每一个在JDBC中都有一个相应的类,并且每个都扩展了java.util.Date 。 这三个中的每一个的快速语义如下: java.sql.Date对应于SQL DATE,这意味着它存储年,月和日,而小时,分钟,秒和毫秒都被忽略。 另外sql.Date并不绑定到时区。 java.sql.Time对应于SQL TIME,显而易见的只包含有关小时,分钟,秒和毫秒的信息 。 j ...
  • 我认为月份的内部编号从0开始,而不是1.因此,您可能需要在某处添加+1。 编辑:在您显示更多代码之后:所需的更改是 String month = form_helper.round(gcal.get(GregorianCalendar.MONTH) + 1); I think internal numbering of months starts with 0, not 1. So, you probably need to somewhere add +1. Edit: after you showed ...
  • 当您打印某些内容时,将调用该对象的toString()方法。 因此,由个别类提供有意义的实现。 供参考,请参阅 Java教程:Object类 这是Date的toString()方法: public String toString() { // "EEE MMM dd HH:mm:ss zzz yyyy"; BaseCalendar.Date date = normalize(); StringBuilder sb = new StringBuilder(28); int index = date.getDa ...
  • 您的教授提供了一个名为Date的自定义类,它与java.util.Date完全无关。 所以你根本无法施放。 如果您确实需要在这两种不同的Date类型之间进行转换,那么您必须编写转换器。 最好的办法是从你的代码java.util.Date移除java.util.Date的输入,并且只使用为这个赋值提供的Date类型。 排序这些日期是可能的,你开始的方式。 您必须重新实现DateComparator以使用自定义Date类而不是java.util.Date 。 You're prof has provided a ...
  • 您在数字中使用的是int literals而不是long 。 默认情况下,整数文字是int除非您在结尾处指定L为long 。 尝试这个: Date d1 = new Date(1000*1373604190L); (注意你文字1373604190末尾的L) You are using int literals instead of long in your numbers. By default a integral literal is int unless you specify that is lo ...
  • 如果您不使用java 7,请删除:在时区部分内 并使用这个: SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); 请参阅Java 6中的SimpleDateFormat的 javadoc 和 如果您使用的是Java 7,请直接使用: SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); 请参阅Java 7中的SimpleDateFo ...
  • 问题在于“May”的解释,因为您没有指定任何区域设置。 尝试: SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", new Locale("en_US")); The problem is the interpretation of "May" because you did not specify any locale. Try : SimpleDateFormat simpleDateForm ...
  • 您可以将数据格式对象的timeZone设置为GMT: df.setTimeZone(TimeZone.getTimeZone("GMT")); 你应该得到你想要的东西。 时间戳表示“自1970年1月1日,格林威治标准时间00:00:00以来的毫秒数”,对于您当前的时区,结果将有所不同。 You can set the timeZone of data format object to GMT: df.setTimeZone(TimeZone.getTimeZone("GMT")); and you sh ...
  • 从Eduardo Macarron(myBatis开发人员)获得解决方案 我知道了。 这是一个有趣的发现。 看看你发布的表达方式。 {reportRunDate mode = IN,jdbcType = DATE}, 没有逗号分隔属性名称和模式! 发生的事情是3.0和3.1承认使用空格作为分隔符,虽然这是未记录的,未经测试,至少在我的情况下未知:) 3.2解析代码得到了改进,现在它支持一个定义良好的语法: 内联参数表达式解析器。 支持的语法(简化): inline-parameter =(propertyN ...
  • 逗号分隔值(CSV)以纯文本格式存储表格数据。 要向Excel提供如何格式化特定列的说明,您需要使用Excel格式。 为了实现它,您可以使用Java库以Excel格式导出数据。 这种库的一个例子是Apache POI - 用于Microsoft文档的Java API( http://poi.apache.org/ )。 此外,为了更好地使用Excel中的CSV文件,请使用从文本导入功能。 这是一个向导,您可以指定导入设置,包括列格式,字段宽度等。 我希望它有所帮助。 Comma-separated valu ...

相关文章

更多

最新问答

更多
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • 电脑高中毕业学习去哪里培训
  • 电脑系统专业就业状况如何啊?
  • IEnumerable linq表达式(IEnumerable linq expressions)
  • 如何在Spring测试中连接依赖关系(How to wire dependencies in Spring tests)
  • Solr可以在没有Lucene的情况下运行吗?(Can Solr run without Lucene?)
  • 如何保证Task在当前线程上同步运行?(How to guarantee that a Task runs synchronously on the current thread?)
  • 在保持每列的类的同时向数据框添加行(Adding row to data frame while maintaining the class of each column)
  • 的?(The ? marks in emacs/haskell and ghc mode)
  • 一个线程可以调用SuspendThread传递自己的线程ID吗?(Can a thread call SuspendThread passing its own thread ID?)
  • 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
  • 悬停时的图像转换(Image transition on hover)
  • IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
  • 没有JavaScript的复选框“关闭”值(Checkbox 'off' value without JavaScript)
  • java分布式框架有哪些
  • Python:填写表单并点击按钮确认[关闭](Python: fill out a form and confirm with a button click [closed])
  • PHP将文件链接到根文件目录(PHP Linking Files to Root File Directory)
  • 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
  • 您是否必须为TFS(云)中的每个BUG创建一个TASK以跟踪时间?(Do you have to create a TASK for every BUG in TFS (Cloud) to track time?)
  • typoscript TMENU ATagParams小写(typoscript TMENU ATagParams lowercase)
  • 武陟会计培训类的学校哪个好点?
  • 从链接中删除文本修饰(Remove text decoration from links)