我需要对在Cpanel服务器上托管的简单Node.js REST API进行原型设计,该服务器使用以下连接连接到MongoDB Atlas集群:
class popup_on_waiver(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setMinimumSize(QSize(660, 340))
self.setWindowTitle("Waiver")
self.cb = QComboBox()
self.cb.setGeometry(QRect(40, 40, 100, 30))
self.cb.addItems(["1", "2", "3", "4"])
self.cb.setObjectName("combobox")
self.cb.move(80, 80)
self.OK = QPushButton('OK')
self.OK.setStyleSheet('QPushButton {font-size: 14px; font: Bold; font-family: Verdana; background-color: Orange; color: White}')
self.OK.move(400, 280)
self.Cancel = QPushButton('Cancel')
self.Cancel.setStyleSheet('QPushButton {font-size: 14px; font: Bold; font-family: Verdana; background-color: Orange; color: White}')
self.Cancel.move(520, 280)
vbox = QVBoxLayout(self)
vbox.addWidget(self.cb)
vbox.addWidget(self.OK)
vbox.addWidget(self.Cancel)
self.OK.clicked.connect(self.hide_main)
self.Cancel.clicked.connect(self.reject)
def hide_main(self):
self.accept()
self.parent().hide()
class Main(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowFlags(Qt.WindowStaysOnTopHint)
self.initUI()
def initUI(self):
self.centralwidget = QWidget(self)
self.Waiver = QPushButton('Waiver')
popup = popup_on_waiver(self)
self.Waiver.clicked.connect(popup.exec_)
hbox = QHBoxLayout()
hbox.addWidget(self.Waiver)
self.centralwidget.setLayout(hbox)
self.setGeometry(50, 50, 1200, 600)
self.setWindowTitle("Timesheet")
self.setWindowIcon(QIcon(""))
self.setStyleSheet("background-color:")
self.setCentralWidget(self.centralwidget)
self.show()
Node.js API运行良好,因为我可以对其执行基本请求,但是与数据库有关的任何事情都以它挂起并返回错误为结束:
“未收到来自应用程序的回复”
检查CPanel日志会显示以下错误:
const mongoose = require('mongoose')
mongoose.connect('mongodb+srv://auser:apassword@cluster0-6bnnw.gcp.mongodb.net/test', {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false
})
测试时:
我已将与地图集内的集群的连接列入白名单(赋予其0.0.0.0)。
我也可以从Studio 3T中使用上述连接字符串访问mongoDB集群,