Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can't connect "https" server #95

Closed
trungdd9 opened this issue Jun 2, 2020 · 3 comments
Closed

Can't connect "https" server #95

trungdd9 opened this issue Jun 2, 2020 · 3 comments

Comments

@trungdd9
Copy link

trungdd9 commented Jun 2, 2020

I cant not connect to my NodeJs localhost with "https://localhost:port
This my client code

`import 'package:flutter/material.dart';

import 'const.dart';
import 'package:socket_io_client/socket_io_client.dart' as IO;
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
IO.Socket socket = IO.io('https://localhost:80', <String, dynamic>{
'transports': ['websocket'],
'autoConnect': false,
'secure':true,
'agent':true,
'rejectUnauthorized': false,
'extraHeaders': {'rejectUnauthorized': false}
});
socket.connect();
print(socket.connected);
socket.on('SERVER_PING', (data)=>print(data));
return MaterialApp(
title: 'Chat Demo',
theme: ThemeData(
primaryColor: themeColor,
),
home: RaisedButton(child: Text("Hello"),onPressed: ()
socket.emit("/test","hello");
//socket.on("/tests",(data)=>print(data));
},),
debugShowCheckedModeBanner: false,
);
}
}

and my servver code:

var express = require('express');
const https = require('https');
//const http=require('http')
var app = express();
const fs = require('fs')
//const server=http.createServer(app)
const server = https.createServer({
key: fs.readFileSync('./ssl_cert/key.key'),
cert: fs.readFileSync('./ssl_cert/cert.cert'),
ca: fs.readFileSync('./ssl_cert/ca.crt')
}, app)
var io = require('socket.io')(server);

io.on('connection', function (socket) {
console.log(socket.id, 'joined');
socket.emit("SERVER_PING","Test")
socket.on('/test', function (msg) {
socket.emit("SERVER_PING","Test")//
socket.emit("/tests","Hello");
console.log(msg);
});
});

var port = 80;
console.log(port);
server.listen(port);`

Tks
Trung

@dogusdicle
Copy link

i have the same problem

@jumperchen
Copy link
Member

FYI: #84

@cgowthamanmca
Copy link

This working?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants