【问题标题】:Change the default timeout for CURL request from roku更改来自 roku 的 CURL 请求的默认超时
【发布时间】:2018-02-04 00:09:51
【问题描述】:

来自 roUrlTransfer 对象的 AsyncPostFromString 方法生成一个超时为 30 秒的 CURL 请求。

即

port = CreateObject ("roMessagePort")
ut = CreateObject ("roUrlTransfer")
ut.setMessagePort(port)
ut.AsyncPostFromString(data)

有谁知道是否有任何方法可以使用 Roku SDK 更改 CURL 超时的默认值?

【问题讨论】:

    标签: roku brightscript


    【解决方案1】:

    我不这么认为 - 或者在 https://sdkdocs.roku.com/display/sdkdoc/ifUrlTransfer 的某处会提到这样的选项 - 就像有 设置最低传输率的调用。

    但请尝试在 Roku 的 dev.forum http://forums.roku.com/viewforum.php?f=34 中提问 - 他们可能会添加该功能。

    【讨论】:

    • 我发现 Roku 有一些问题。你发现有没有解决办法。在 Postmantool 中,我的响应时间是 1 分钟,但我默认设置为 0。并应用 roTimeSpan 设置毫秒或秒,但它给出一个错误(执行超时(运行时错误 &h23))。他们在 Roku 中有任何可用的解决方案吗?
    【解决方案2】:

    无法更改请求的默认超时。但是您可以在管理异步请求处理程序中的超时时手动执行此操作。大多数应用程序应该使用异步请求,所以无论如何你都会做类似的检查。另外请务必在roUrlTransfer 上致电asyncCancel() 以清理请求。

    ' given a url that will timeout
    url = "http://www.mocky.io/v2/5a75d6902e000068006ab21a?mocky-delay=1000ms"
    
    ' and a timeout in ms
    timeout = 100
    
    ' create a roUrlTransfer for the request
    urlTransfer = CreateObject("roUrlTransfer")
    urlTransfer.setUrl(url)
    port = CreateObject("roMessagePort")
    urlTransfer.setMessagePort(port)
    
    ' request the URL
    if urlTransfer.asyncGetToString()
        event = wait(timeout, port)
        if type(event) = "roUrlEvent"
            print "urlTransfer success"
    
        else if event <> invalid
            print "event emitted: " + type(event)
    
        else
            print "urlTransfer timed out"
            urlTransfer.asyncCancel()
    
            ' alternatively: measure the request time against timeout using roTimeSpan
        end if
    end if
    

    如代码中所述,如果您正在处理等待循环中的其他请求(在等待超时与请求超时不同的情况下),您将需要使用 roTimeSpan 测量超时。

    【讨论】:

    • 你好@Jess Bowers,我需要在urlTransfer.asynccancel() Block 中显示一个对话框。但任务节点不支持对话框。有什么方法可以显示对话框。我尝试了很多方法使用 getparent() 但还没有显示。
    猜你喜欢
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    • 2014-07-18
    • 2014-06-22
    • 1970-01-01
    • 2011-01-15
    • 1970-01-01
    • 2012-05-05
    相关资源
    最近更新 更多