Comments (10)
This plugin works well on HTTPS, at least with standard port 443
please add error
event handler as following and see the outcome
const SocketIO = require('nativescript-socket.io');
let socket = SocketIO.connect(ENDPOINT);
socket.on('error', (error) => {
console.dump(error);
});
from nativescript-socket.io.
on my server i create certificate :
openssl genrsa -out key.pem
openssl req -new -key key.pem -out csr.pem
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
rm csr.pem
and node server :
var fs = require('fs');
var options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
var app = require('https').createServer(options,handler)
var io = require('socket.io')(app);
app.listen(8000);
function handler (req, res) {
fs.readFile(__dirname + '/index.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
i cannot conect
var SocketIO = require('nativescript-socket.io');
SocketIO.enableDebug(); // optionnal
var socket = SocketIO.connect('https://192.168.1.185:8000', []);
socket.on('connect', function(){
console.log('connect berhasil');
});
socket.on('error', (error) => {
console.log('error');
console.dump(error);
});
and no error
from nativescript-socket.io.
please do curl -v https://192.168.1.185:8000/socket.io/
if that outcomes {"code":0,"message":"Transport unknown"}
then you should be able to connect, otherwise I have no idea what is happening here
from nativescript-socket.io.
this is result from my web production
Kreasindos-MacBook-Pro:~ kct$ curl -v https://demo.worksaurus.com:58082/socket.io/
* Trying 128.199.84.205...
* Connected to demo.worksaurus.com (128.199.84.205) port 58082 (#0)
* TLS 1.2 connection using TLS_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.worksaurus.com
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET /socket.io/ HTTP/1.1
> Host: demo.worksaurus.com:58082
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Date: Thu, 30 Mar 2017 15:54:07 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
<
* Connection #0 to host demo.worksaurus.com left intact
{"code":0,"message":"Transport unknown"}
and i still cannot connet to the socket
from nativescript-socket.io.
it'is my javascript code
var createViewModel = require("./main-view-model").createViewModel;
function onNavigatingTo(args) {
var page = args.object;
page.bindingContext = createViewModel();
var SocketIO = require('nativescript-socket.io');
SocketIO.enableDebug(); // optionnal
var socket = SocketIO.connect('https://demo.worksaurus.com:58082', []);
socket.on('connect', function(){
console.log('connect berhasil');
});
socket.on('error', (error) => {
console.log('error');
console.dump(error);
});
for(var i in socket.android){
console.log(i);
}
console.log("hasil : "+socket.android.connected());
}
exports.onNavigatingTo = onNavigatingTo;
from nativescript-socket.io.
Could you try directly to my socket production ?
from nativescript-socket.io.
please test with standard port for HTTPS (443), with android and ios
this could be a port issue
from nativescript-socket.io.
@wiliarko is this issue persisting?
from nativescript-socket.io.
@wiliarko if you are using this with android, it won't connect, since android doesn't support non-standard ports over https, hence 443. You will either need to proxy it or run it over 443 as suggested.
from nativescript-socket.io.
thank you @zoeitsolutions for the clarification.
@wiliarko I presume this sorts the matter out .. closing
from nativescript-socket.io.
Related Issues (20)
- Reconnection
- need upgrade to {N} V4 ? HOT 2
- Can I use this plugin in NativeScript Angular? HOT 1
- IOS `init` is depricated HOT 8
- strange behavior can't build nativescript-socket.io HOT 3
- iOS Swift 4.0 Build Failed HOT 1
- Use websocket only on android HOT 22
- Plugin is not compatible with xcode 10.2 HOT 4
- Flavor 'nativescript-socket.io' has unknown dimension 'nativescriptsocketio' HOT 1
- Deprecated? HOT 1
- use with feathersjs HOT 1
- Not working on android :( HOT 23
- tns plugin add nativescript-socket.io is not working with 0.11.0 HOT 1
- IOS Build failed
- Event subscription never fires iOS
- Disconnect issue
- Cant connect to server without path HOT 1
- Cant connect to nodejs socket v4 with io.socket:socket.io-client v1 HOT 3
- Issue with include.gradle and keyword "compile" on NS 8 HOT 2
- Fails to build
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-socket.io.