tlantic / cdv-socket-plugin Goto Github PK
View Code? Open in Web Editor NEWCordova Socket Plugin
License: GNU General Public License v3.0
Cordova Socket Plugin
License: GNU General Public License v3.0
The Plugin is crashing when you try to DisconnectAll connections, it is raising the following Exception: Collection was mutated while being enumerated
On iOS, when receiving a large amount of data (more than TCP layer handles at once) the data sent to JS bridge is being splitter in several packs.
When running out of resources (memory, cpu) the plugin exposes multiple locks on web view, throwing bool_WebTryThreadLock(bool) exceptions.
This exception put the application in a starving scenario, with no answer from plugin.
through this event, iOS plugin must to clean connection pool because the server or other external condition decide to terminate the connection itself.
connected to some server, server sent some data to android app, but the “SOCKET_RECEIVE_DATA_HOOK” event won't trigger util a disconnection is made by server / cdv-socket-plugin. I use the android v19 sdk. Is this caused by the android API difference between versions?
If the connection does not succeed, the socket is being stored in pool anyway.
The 'Send' example on readme is differently if compared with the implementation in www/Socket.js:
send (successCallback, errorCallback, host, port, data)
Should be "send (successCallback, errorCallback, connectionId, data)" as is on socket.js line 31;
Also there's a silent bug as you can see on the other sample functions, the IP is such this: '192.168.2..5', with two dots after the number 2.
This event basically could use a unsigned int for length var. Please check the following reference:
Add support for Windows 8 Store Apps platform covering same features implemented for iOS and Android on previous versions.
Currently, socket operations require host and port. This can be improved. After connect operation, it should return the connection id to make easier future socket operations.
There's is a variable name conflict on Connection.m file on the Write Method, the var Chunk is conflicting with other variable with the same name, the other one is declared on connection.h file.
Need to change the name of some of these.
Use NSStreamEventOpenCompleted event to save connection into the pool. That helps to fix the problem about saving trash into connection pool.
The result of connect method should be a string containing the "connection id" instead of a message, which is useless.
This is related to issue #53 where the same was requested for iOS.
(I don't know if the user who raised that issue also wanted receive support, but in my application I only need to send binary data).
I propose addition of a new method:
sendBinary(successCallback, errorCallback, connectionId, data)
In this case data is a JSONArray, one byte per element, so it may be called as follows:
window.tlantic.plugins.socket.sendBinary(
function() {
console.log('sent')
},
function(error) {
console.log('failed to send: '+error)
},
connectionId,
[ 0x01, 0x00, 0x01, 0xFD ]
);
Expose on iOS method a way to check connection status.
When trying to connect, the following error message is logged on failure calback:
WinRTError: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
iOS disconnect method is nor disposing socket connections when calling "disconnect"
I try to establish a connection between an iOS 8 device and an Android 4.4 device and at first I get the message: Established connection with 192.168.178.20:18002
Few milliseconds later I get «Cannot connect to the host!».
The network is up, no firewall, etc. Is there a way to get a more detailed Error-Message?
On Android plugin, "disconnect" triggers the thread end, closing the socket connection. However, the object reference is not being removed from Pool hash map.
IMHO your plugin forces all applications that uses it to be licensed under GPL as well. And I'm not sure if they will ever be accepted by Apple on submission. Any chance to make the plugin dual license?
Instead of following POC approach, the operations over a connection (send, disconnect, etc..) will use the connection id as reference instead of host and port every time something must be done.
Hi,
Maybe I'm wrong but I tried to connect to a server with this plugin without success.
Usually on windows I use the Telnet client to connect and send commands to the server.
I tried the client sample but I have connection issues and I can't sent messages.
Am I doing something wrong ?
Thanks a lot,
Kreshnik
PS :
IP : "192.168.211.130"
Port : 5007
Handle NSStreamEventErrorOccurred event to clean connection pool and release resources if something bad happens. Maybe we can think about a new feature to establish connection in this case.
From javascript code there is no access to connection status. Need to expose socket.isConnected or other similar information to have JS code able to take decisions about TCP socket management.
Please see #36 .
The buffer size has to be a socket channel configuration, avoiding undesirable data truncation/chopping when receiving data from the server.
The original issue (#32) refers to iOS but it must to be checked in all platforms.
Android isConnected is not assertive when checking socket connection. We need to improve the connection check to provide a mechanism for apps checking the connections status.
Add support for Windows Phone 8 platform covering same features implemented for iOS and Android on previous versions.
If possible, try to reuse W8 code.
Hey I'm back again :) Very Thankful for that fix last release it was brilliant, This plugin is getting more and more better. Though i do have some pretty weird behavior i encountered not sure if it was only me, but might need you to check and test if plugin works with this kind of return:
{
"Type":"nowplaying",
"Duration":2458,
"Position":0,
"IsTv":false,
"IsFullscreen":true,
"File":"",
"MediaInfo":{
"MediaType":"series",
"SeriesId":76290,
"SeasonId":10063,
"EpisodeId":189255,
"Series":"24",
"Season":1,
"Episode":1,
"Title":"Tag 1: 00:00Uhr-01:00Uhr",
"AirDate":"2001-11-06",
"Director":"Stephen Hopkins",
"Writer":"Robert Cochran, Joel Surnow",
"Genre":"|Action and Adventure|Drama|",
"ImageName":"c:\images\series\24.jpg",
"MyRating":"",
"Plot":"Stressiger Abend f\U00fcr CTU-Agent Jack Bauer: Seine halbw\U00fcchsige Tochter Kimberly stiehlt sich unerlaubt aus dem Haus. Aber bevor er sich auf die Suche machen kann, wird er dringend ins B\U00fcro zitiert, denn Terroristen planen einen Anschlag auf Senator David Palmer. Es scheint eine lange Nacht f\U00fcr den Agenten zu werden…",
"Rating":"7.5",
"RatingCount":"",
"Status":"Ended"
}
}
The current implementation works only with String objects. Would be nice having the plugin JS file verifying the object type before sending/receiving data, calling JSON.stringify and JSON.parse when needed.
Hi, i have problem with the function call receivehook;
I have a server w/c i have no way of editing the response and im stuck with the single quotes problem, here is a sample response and call:
window.tlantic.plugins.socket.receive('192.168.43.151',8017,'192.168.43.151:8017','{"Type":"status","IsPlaying":true,"IsPaused":false,"IsPlayerOnTop":false,"Title":"Now That You're Gone","CurrentModule":"Music/shares","SelectedItem":"12. Juris Fernandez - Now That You're Gone","WindowId":501}');
isConnected action is missing on android plugin.
Hi Vinny and Felipe,
I'm the coordinator of the BlackBerry Tech Center Brazil and I'm developing the support of BlackBerry 10 socket into your plugin and I wish to send you a pull request when I finish it. Do you have interest on that?
Thank,
Leandro.
Connect method does not verify if there is a connection already opened.
When receiving the data in two or more chunks, the plugin is splicing the first chunk, returning an invalid buffer.
Today It's not possible to transmit buffer with more than 1024 bytes.
Send method does not validate socket connection before trying to write on output stream.
Add basic support for iOS, covering the same features v0.1.0 has for Android.
It shouldn't set Null to the pool since there is no connections inside of it?
My suggestion is to test if the Connection Pool count is Zero and if it's true set null to it, cause every time you invoke Connect it's checking if the Pool is null and if it's true it init the pool.
if ([pool count] == 0) {
pool = nil;
}
Make sense?
iOS implementation should check stream status before return Open Callback.
It seems that binary communication is not supported, looking at -[Connection write:]
and -[Connection stream:(NSStream*) handleEvent:(NSStreamEvent)]
, where NSASCIIStringEncoding
is used. Is it so? In this case, would it be possible to add binary data support?
It makes code easier to be read...
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.