簡體   English   中英

Nodejs / Nginx服務器(AWS)/ Mysql / insert 502 Bad Gateway錯誤

[英]Nodejs/ Nginx server(AWS)/ Mysql/ insert 502 Bad Gateway error

當我嘗試使用Mysql,AWS ElasticBeanstalk Nginx服務器插入一些文本時,

它有時會出現502 Bad Gateway的錯誤消息。

只插入大小寫錯誤(選擇,更新,刪除工作正常。)

如果我嘗試在localhost中插入,它運行得很好。

 <form action="/finance" method="post"> <div class="input-field col l12"> <input name="consult_name" type="text"> <input type="submit" value="send"> </div> </form> 

 router.post('/finance', function(req, res, next) { var consult_name = req.body.consult_name; console.log(consult_name); var sets = {consult_name : consult_name}; mysql.insert('insert into cider.cid_finance set ?', sets, function (err, data){ res.redirect('/finance'); }); }); 

 2016/08/30 22:04:24 [error] 29838#0: *52 upstream prematurely closed connection while reading response header from upstream, client: 115.95.162.173, server: , request: "POST /finance HTTP/1.1", upstream: "http://127.0.0.1:8081/finance", host: "cidermics.com", referrer: "http://cidermics.com/finance" 2016/08/30 22:04:24 [error] 29838#0: *52 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 115.95.162.173, server: , request: "POST /finance HTTP/1.1", upstream: "http://127.0.0.1:8081/finance", host: "cidermics.com", referrer: "http://cidermics.com/finance" 

AWS ElasticBeanstalk錯誤日志

 /var/app/current/node_modules/mysql/lib/protocol/Parser.js:77 throw err; // Rethrow non-MySQL errors ^ Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1 at Query.Sequence._packetToError (/var/app/current/node_modules/mysql/lib/protocol/sequences/Sequence.js:48:14) at Query.ErrorPacket (/var/app/current/node_modules/mysql/lib/protocol/sequences/Query.js:83:18) at Protocol._parsePacket (/var/app/current/node_modules/mysql/lib/protocol/Protocol.js:280:23) at Parser.write (/var/app/current/node_modules/mysql/lib/protocol/Parser.js:73:12) at Protocol.write (/var/app/current/node_modules/mysql/lib/protocol/Protocol.js:39:16) at Socket.<anonymous> (/var/app/current/node_modules/mysql/lib/Connection.js:98:28) at emitOne (events.js:77:13) at Socket.emit (events.js:169:7) at readableAddChunk (_stream_readable.js:153:18) at Socket.Readable.push (_stream_readable.js:111:10) 

你的sql語法錯了。 錯誤消息清楚地表明mysql語法是問題所在。

嘗試這個:

mysql.insert('insert into cider.cid_finance set consult_name = ?', consult_name,  function (err, data){

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM