roku - 任务节点执行超时
问题描述
我遇到了任务节点的问题(执行超时)。我在场景节点中为连续执行功能创建了一个计时器,在这里我尝试使用任务节点进行连续响应更新,然后在场景节点中使用它。
'定时器
m.Update = m.top.findNode("SampleID")
m.Update .observeField("fire", "UpdateSample")
m.global.responseurl = m.urlassign
m.Update.control = "RUN"
'我的功能
function UpdateSample()
m.Sample= CreateObject("roSGNode", "SampleTask")
m.Sample.control = "RUN"
?"m.global.responsecontent : " m.global.responsecontent
end function
'我的任务节点
sub init()
?"Start Init()"
m.DowndloadResponse = CreateObject("roUrlTransfer")
m.DowndloadResponse.SetUrl(m.global.responseurl)
m.Cont= m.DowndloadResponse.GetToString()
m.global.responsecontent = m.Cont
?"m.global.responsecontent : " m.global.responsecontent
?"End Init()"
end sub
在这里,不是每次都得到 DowndloadResponse.GetToString() "Execution TimeOut"。有时它会出错。我尝试使用 m.top.functionname。但它立即执行。我还尝试在任务节点中设置计时器。但没有运气。我要求它是多个。我不知道哪个是实现这一点的好方法。有谁知道如何解决这个问题?
解决方案
您错误地使用了 Task 节点,您必须绝对使用functionName
.
我还建议使用asyncGetToString()
它,因为它可以让您阅读响应代码。您还必须为 HTTPS 请求设置和初始化证书(Roku 标准证书包应该这样做)。
你的任务线程函数中应该有这样的东西:
request = CreateObject("roUrlTransfer")
request.retainBodyOnError(true)
request.setUrl(url)
' Needed for HTTPS requests
request.setCertificatesFile("common:/certs/ca-bundle.crt")
request.initClientCertificates()
port = CreateObject("roMessagePort")
request.setPort(port)
timeout = 0 ' Force a timeout (0 equals "indefinite", or until Roku decides to terminate the request... ~60s)
event = wait(timeout, port)
if event <> invalid and type(event) = "roUrlEvent"
?"event.getString() "event.getString()
?"event.getResponseCode() "event.getResponseCode()
?"event.getFailureReason() "event.getFailureReason()
end if
' Ensure the request does not continue to run after the forced timeout is hit
' (Only necessary if you set a non-zero timeout)
request.asyncCancel()
推荐阅读
- excel - “运行时错误'1004':我们无法粘贴此数据,因为它花费了太长时间。请尝试减小选择的大小。”
- flutter - Flutter 从 JSON 导出 pdf
- html - 关于excel VBA导航网站html的问题
- python - 是否可以在没有参考的情况下加入 2 个 django 模型?
- javascript - 为什么 req.body 返回一个空对象?
- c# - TaskContinuations 与异步 lambda 同步运行
- laravel - Laravel 5.7:是否可以在表中直接添加值?
- jmeter - 如何获取活动线程组中当前步骤的活动线程数?
- sql - 在会话监视器中的 SQL 文本查询以不同的方式设置
- asp.net-core - Partial 标签助手是否使用 RenderPartialAsync 或 PartialAsync