rolandoislas / brightwebsocket Goto Github PK
View Code? Open in Web Editor NEWRFC 6455 WebSocket Library for the Roku
License: Other
RFC 6455 WebSocket Library for the Roku
License: Other
Hi there,
I made some app and when I send to the roku client with this library more messages at once like 50 messages in 10-20 ms interval app will crash with stack trace below:
Suspending threads...
Thread selected: 1* ...tlibrary:/WebSocketClient.brs(634) send(message, m.OPCODE_CLOSE)
Current Function:
627: function send_close_frame(code, reason)
628: message = createObject("roByteArray")
629: message.push(code >> 8)
630: message.push(code)
631: if reason <> invalid
632: message.append(reason)
633: end if
634:* send(message, m.OPCODE_CLOSE)
635: end function
Stack overflow. (runtime error &hdf) in mycomponentlibrary:/WebSocketClient.brs(634)
634: send(message, m.OPCODE_CLOSE)
Backtrace:
#69 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#68 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#67 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#66 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#65 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#64 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#63 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#62 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#61 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#60 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#59 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#58 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#57 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#56 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#55 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#54 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#53 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#52 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#51 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#50 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#49 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#48 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#47 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#46 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#45 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#44 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#43 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#42 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#41 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#40 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#39 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#38 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#37 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#36 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#35 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#34 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#33 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#32 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#31 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#30 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#29 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#28 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#27 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#26 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#25 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#24 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#23 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#22 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#21 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#20 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#19 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#18 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#17 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#16 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#15 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#14 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#13 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#12 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#11 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#10 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#9 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#8 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#7 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#6 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#5 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#4 Function send(message As Dynamic, _opcode As Integer) As Boolean
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#3 Function send_close_frame(code As Dynamic, reason As Dynamic) As Dynamic
file/line: mycomponentlibrary:/WebSocketClient.brs(634)
#2 Function close() As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(611)
#1 Function send(message As Dynamic) As Integer
file/line: mycomponentlibrary:/WebSocketClient.brs(226)
#0 Function run() As Void
file/line: mycomponentlibrary:/WebSocketClient.brs(70)
Local Variables:
code Integer val:1000 (&h3E8)
reason bsc:roInvalid refcnt=2
global Interface:ifGlobal
m roAssociativeArray refcnt=71 count:36
message bsc:roByteArray refcnt=1
Threads:
ID Location Source Code
0 pkg:/source/main.brs(15) msg = wait(0, m.port)
1* ...tlibrary:/WebSocketClient.brs(634) send(message, m.OPCODE_CLOSE)
*selected
I was trying to investigate what actually happen but didn't find it.
I think this stack trace is actually another fail and feel like system break the app due to long term operation, the loop on roPortMessage is receiving message every 66 ms, so system queue incoming messages which are looking like big one.
PS: I am using the WebSocketClient lib in my ComponentLibrary, I tried put it into app ahead but it worked same, I have model 4200X - Roku 3, older but Software is 8.1.0
In a case I want use it in ComponentLibrary, I am unable to access it-self path as pkg:/
which is path of main application and not current component, even it is strange I am actually unable to read files of it-self in brightscript.
Change it to be assocarray field with default value of this task, please.
Hi, very interested to see where this project goes, but was wondering if there is any further thoughts on the outstanding notes especially the secure sockets?
I’m anxious to try out this code but its dependence upon Task is a non-starter, unfortunately. The fields in the XML interface cross a thread boundary which would incur a huge amount of overhead in the low-level protocol handling, and also suggests that any processing of received data would happen in the render thread.
I’d really like to see this refactored into pure BRS code and not use any scene graph in its core, then possibly add a Task as a wrapper only.
if I create a big json data and convert it into string my app crash because Execution timeout, I was debugging for it and figured out there is a lot of work with roByteArray which is expensive for performance, not sure if change to work with string instead will improve it but at least there is 1 loop(for) which contains next 2 loops(for) it could be merged into one, here is some test:
function time_test_orig(test_string as string) as dynamic
_FRAME_SIZE = 1024
timer = createObject("roTimespan")
timer.mark()
' bytes = createObject("roByteArray")
' bytes.fromAsciiString(test_string)
frame_count = bytes.count() \ _FRAME_SIZE
if bytes.count() mod _FRAME_SIZE <> 0 or frame_count = 0
frame_count++
end if
max = bytes.count() - 1
for frame_index = 0 to frame_count - 1
payload = createObject("roByteArray")
for byte_index = frame_index * _FRAME_SIZE to max
payload.push(bytes[byte_index])
end for
end for
' ?"[TIME]:";timer.TotalMilliseconds()
return timer.TotalMilliseconds()
end function
then I did call, to make more relative data I will call it many times to make average time:
t = 0
repeat = 50
test_string = "ásdaas{}asd asd asxcvxcv dsf;'ad][][a{}asda]xcvvdfedzsfdsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaassssssssssssssssssssssssssssssssssssssssssssddddddddddddddddddddddddddddddddddddddddddddddfdsfddfgdfggt546545465434yrtyrty5676578667tygh df hdgfh dhgf yhdgfhrt 2qtt 345 344rdfgdfghdgf sfaasdasdasxxcvxcvxc'"
test_string += test_string + test_string + test_string + test_string
test_string += test_string + test_string' + test_string + test_string
for i = 0 to repeat
t += time_test(test_string)
end for
?"OVERALL: "; t/repeat; len(test_string)
also would be nice to write down some unit tests in this project. There are 2 unit tests components at least for brightscript.
I could do PR with those changes but, want to be sure what is the reasons.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.