Parse-Server 安装中的 MongoError write EPIPE”

Posted

技术标签:

【中文标题】Parse-Server 安装中的 MongoError write EPIPE”【英文标题】:MongoError write EPIPE” in Parse-Server Installation 【发布时间】:2016-04-25 23:12:12 【问题描述】:

我正在帮助一位朋友将 Parse 应用程序迁移到专用服务器而不是托管服务提供商,但我在尝试解决我认为服务器上的 Parse Server 实例中发生的错误时遇到了困难。

首先,这是来自 PM2 日志的错误堆栈,每次向服务器发送 GET 或 POST 时都会抛出该堆栈:

parse-wrapper-0 (err):     at null.<anonymous> (/usr/lib/node_modules   /parse-server/node_modules/mongodb-core/lib/connection/pool.js:119:12)
parse-wrapper-0 (err):     at g (events.js:273:16)
parse-wrapper-0 (err):     at emitTwo (events.js:100:13)
parse-wrapper-0 (err):     at emit (events.js:185:7)
parse-wrapper-0 (err):     at Socket.<anonymous> (/usr/lib/node_modules/parse-server/node_modules/mongodb-core/lib/connection/connection.js:144:49)
parse-wrapper-0 (err):     at Socket.g (events.js:273:16)
parse-wrapper-0 (err):     at emitOne (events.js:90:13)
parse-wrapper-0 (err): error: Uncaught internal server error.  [MongoError: server localhost:27017 received an error "name":"MongoError","message":"write EPIPE"]
parse-wrapper-0 (err):   name: 'MongoError',
parse-wrapper-0 (err):   message: 'server localhost:27017 received an error "name":"MongoError","message":"write EPIPE"'  MongoError: server localhost:27017 received an error "name":"MongoError","message":"write EPIPE"
parse-wrapper-0 (err):     at null.<anonymous> (/usr/lib/node_modules/parse-server/node_modules/mongodb-core/lib/topologies/server.js:308:40)
parse-wrapper-0 (err):     at emitTwo (events.js:100:13)
parse-wrapper-0 (err):     at emit (events.js:185:7)
parse-wrapper-0 (err):     at null.<anonymous> (/usr/lib/node_modules/parse-server/node_modules/mongodb-core/lib/connection/pool.js:119:12)
parse-wrapper-0 (err):     at g (events.js:273:16)
parse-wrapper-0 (err):     at emitTwo (events.js:100:13)
parse-wrapper-0 (err):     at emit (events.js:185:7)
parse-wrapper-0 (err):     at Socket.<anonymous> (/usr/lib/node_modules/parse-server/node_modules/mongodb-core/lib/connection/connection.js:144:49)
parse-wrapper-0 (err):     at Socket.g (events.js:273:16)
parse-wrapper-0 (err):     at emitOne (events.js:90:13)

由于我不太确定问题的性质(我查看了 write EPIPE 错误是什么,但不确定为什么它会在 GET 上发生或为什么每次都会关闭),我只是给出我能想到的与此相关的服务器的所有信息。

这是目前的相对用户结构:

root -defuser:运行 mongo 实例以及 nginx -parse:通过 PM2 运行解析

这是 PM2 正在使用的生态系统.json 文件:


  "apps":[
    "name" : "parse-wrapper",
    "script" : "/usr/bin/parse-server",
    "watch" : true,
    "merge_logs" : true,
    "cwd" : "/home/parse",
    "env" : 
      "PARSE_SERVER_CLOUD_CODE_MAIN": "cloud/main.js",
      "PARSE_SERVER_DATABASEURI": "mongodb://parse:SUPERPASSWORDHERE@domain.here:27017/beerdb?ssl=true",
      "PARSE_SERVER_APPLICATION_ID": "super secret Parse key",
      "PARSE_SERVER_MASTER_KEY" : " master key"
   
  ]

这是 mongo.conf 文件:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0
  ssl:
    mode: requireSSL
    PEMKeyFile: /etc/ssl/mongo.pem


#processManagement:

security:
  authorization: enabled

#operationProfiling:

#replication:

#sharding:

setParameter:
  failIndexKeyTooLong: false

## Enterprise-Only Options:

#auditLog:

#snmp:

我不认为 nginx 与此有任何关系,但这里的配置无论如何:

# HTTP - redirect all requests to HTTPS
server 
    listen 80;
    listen [::]:80 default_server ipv6only=on;
    return 301 https://$host$request_uri;


# HTTPS - serve html from /usr/share/nginx/html, proxy requests to /parse/
# through to Parse Server
server 
    listen 443;
    server_name domain.here;

    root /usr/share/nginx/html;
    index index.html index.htm;

    ssl on;
    # Use certificate and key provided by Let's Encrypt:
    ssl_certificate /etc/letsencrypt/live/domain.here/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain.here/privkey.pem;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

    # Pass requests for /parse/ to Parse Server instance at localhost:1337
    location / 
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://localhost:1337/parse/;
            proxy_ssl_session_reuse off;
            proxy_set_header Host $http_host;
            proxy_redirect off;
    



我在这里基本上没有想法,虽然我不是一个专家,不仅仅是设置 Apache,所以这可能是一个愚蠢的疏忽或我的头脑。因此,如果有任何帮助,我们将不胜感激,如果是简单的,我们深表歉意。

【问题讨论】:

【参考方案1】:

我的部署遇到了同样的问题。事实证明 Parse Dashboard 与 MongoDB 建立了很多连接(在我的情况下 > 1k 连接),因此我们必须增加 mongo.conf 中的最大连接限制和文件描述符限制(取决于您的操作系统)。

例如,在 Linux 中:

编辑mongo.conf文件并添加maxConns = 10000 编辑/etc/sysctl.conf文件并添加fs.file-max = 10000 正在运行ulimit -n 50000

【讨论】:

fs.file-max = 1000000 in sysctl.conf 为我解决了一个问题,即 GridFS 在尝试使用 ~500MB 文件时导致上述错误。

以上是关于Parse-Server 安装中的 MongoError write EPIPE”的主要内容,如果未能解决你的问题,请参考以下文章

启动和停止 Parse-Server 和 Parse-Server 仪表板

parse-server:如何区分用户类 BeforeSave 中的 signUp 和常规 ParseUser.save?

如何在 Parse-Server 中实现“protectedFields”?

Parse-server:iOS 推送通知

Parse-Server - 无法从远程机器上的数据库中获取数据

Parse-Server 云代码查询不返回所有列