Socket.io与iisnode https windows server 2012。

问题描述 投票:0回答:1

大家好,我有一个养安全套接字的问题,我看了很多解决方案,也试了很多解决方案,但都不适合我,我详细介绍一下特点。

  • 服务器: Windows Server 2012 R2 Standard
  • 系统类型。64位
  • IIS版本: 8.5
  • Node版本:6.12.0

服务器有https的证书,附上我对socket的配置和web.config。

服务器.js

const express = require("express");
const https = require("https");
var bodyParser = require("body-parser");
const socketIO = require("socket.io");
require('events').EventEmitter.defaultMaxListeners = 0
const app = express();
var server = https.createServer({ 
                key: fs.readFileSync('certs/extra/file.pem'),
                cert: fs.readFileSync('certs/extra/file.crt')
             },app);
const io = socketIO(server);

io.on("connection", socket => {
    try {
        console.log("new id:" + socket.id);
    } catch (ex) {
        console.log(ex)
    }
});
app.get("/", function(req, res) {
    res.send("<h1>SOCKET TEST</h1>");
});

app.post('/api/users/list', function (req, res) {
    res.send('Testing route path')
});
server.listen(process.env.PORT, "192.168.4.23");

Web.config

  <system.webServer>
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
    </handlers>
    <rewrite>
      <rules>
        <rule name="myapp">
           <match url="api/*" />
          <action type="Rewrite" url="server.js" />
        </rule>
        <rule name="myapp3">
           <match url="/*" />
          <action type="Rewrite" url="server.js" />
        </rule>
        <rule name="myapp2">
           <match url="socket.io"/>
          <action type="Rewrite" url="server.js" />
        </rule>
      </rules>
    </rewrite>
     <webSocket enabled="true" />
  </system.webServer>
</configuration>

IIS

IIS配置

试图连接时的响应试图连接时的图像响应

https socket.io windows-server-2012-r2 iis-8.5 iisnode
1个回答
0
投票
let user = console.log(https://localhost)

使用:服务器:Windows Server 2012 R2 ..: Windows Server 2012 R2 StandardSystem类型:Windows Server 2012 R2 StandardSystem类型。64位IIS版本:8.5Node版本:6.12.0

© www.soinside.com 2019 - 2024. All rights reserved.