SQL Server NodeJS应用程序在请求MSSQL DB时崩溃

lndjwyie  于 2022-12-03  发布在  其他
关注(0)|答案(1)|浏览(136)

大家好!
我有一个老的应用程序从开发,现在不工作在我们公司。我需要启动这个应用程序,但没有足够的经验在NodeJS(我没有它在所有,TBH)。
问题是:我可以构建一个Docker映像,启动它,然后使用应用程序,但是当我创建需要向MQSQL服务器发出请求的内容时,应用程序崩溃。但是向Postgres DB发出请求时没有问题。
这是我的Docker构建输出

docker build -t fixver .
Sending build context to Docker daemon  2.427MB
Step 1/21 : FROM node:16-alpine as base
 ---> c4ee3c9d7bc1
Step 2/21 : ARG NODE_ENV=production
 ---> Using cache
 ---> ba79cfac2e2c
Step 3/21 : ENV NODE_ENV=${NODE_ENV}     NODE_OPTIONS="--max_old_space_size=8192"
 ---> Using cache
 ---> 1a344f8791d8
Step 4/21 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 1c591a772bcd
Step 5/21 : FROM base as clientBuilder
 ---> 1c591a772bcd
Step 6/21 : COPY ./client/package.json ./client/yarn.lock ./
 ---> Using cache
 ---> 7382b944fcc0
Step 7/21 : RUN yarn install --production=false --frozen-lockfile
 ---> Using cache
 ---> 431700be035b
Step 8/21 : COPY ./client .
 ---> Using cache
 ---> 87790e7c061a
Step 9/21 : RUN yarn build
 ---> Using cache
 ---> 9ba70dd8301c
Step 10/21 : FROM base as serverBuilder
 ---> 1c591a772bcd
Step 11/21 : COPY ./server/package.json ./server/yarn.lock ./
 ---> Using cache
 ---> bf5dc70ee2eb
Step 12/21 : RUN yarn install --production=false --frozen-lockfile
 ---> Using cache
 ---> c26b02f2af5c
Step 13/21 : COPY ./server .
 ---> 16fdc772d650
Step 14/21 : RUN yarn build
 ---> Running in 676753d20a77
yarn run v1.22.19
$ node_modules/.bin/rimraf dist
$ node_modules/.bin/nest build
Done in 5.75s.
Removing intermediate container 676753d20a77
 ---> 66a53b6af7cd
Step 15/21 : FROM base as production
 ---> 1c591a772bcd
Step 16/21 : COPY ./server/package.json ./server/.env ./
 ---> dbbbe7295cfd
Step 17/21 : RUN yarn install --pure-lockfile
 ---> Running in f3b965d1ec0d
yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
warning Resolution field "uuid@8.3.2" is incompatible with requested version "uuid@^3.1.0"
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > ts-loader@9.4.2" has unmet peer dependency "webpack@^5.0.0".
[4/4] Building fresh packages...
Done in 39.04s.
Removing intermediate container f3b965d1ec0d
 ---> 8d804071a8d2
Step 18/21 : COPY --from=serverBuilder /usr/src/app/dist ./
 ---> f760fda4b1a1
Step 19/21 : COPY --from=clientBuilder /usr/src/app/build ./public
 ---> 4f697bab8bc6
Step 20/21 : EXPOSE 80
 ---> Running in 95fae0df9266
Removing intermediate container 95fae0df9266
 ---> 4bebff7957bc
Step 21/21 : CMD ["node", "./main"]
 ---> Running in 19b4df36b37e
Removing intermediate container 19b4df36b37e
 ---> 362fbadf0b4a
Successfully built 362fbadf0b4a
Successfully tagged fixver:latest

启动应用程序

docker run -p 7007:80 fixver
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [NestFactory] Starting Nest application...
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [InstanceLoader] AppModule dependencies initialized +60ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [InstanceLoader] PassportModule dependencies initialized +1ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [InstanceLoader] ConfigHostModule dependencies initialized +1ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [InstanceLoader] ServeStaticModule dependencies initialized +0ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [InstanceLoader] ConfigModule dependencies initialized +1ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [InstanceLoader] AuthModule dependencies initialized +8ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [InstanceLoader] PagesModule dependencies initialized +0ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [InstanceLoader] ScriptsModule dependencies initialized +1ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [RoutesResolver] ScriptsController {/api/scripts}: +8ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [RouterExplorer] Mapped {/api/scripts, GET} route +4ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [RouterExplorer] Mapped {/api/scripts/:id, GET} route +1ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [RouterExplorer] Mapped {/api/scripts/:id/check, POST} route +0ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [RouterExplorer] Mapped {/api/scripts/:id/apply, POST} route +1ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [RoutesResolver] PagesController {/api/pages}: +1ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [RouterExplorer] Mapped {/api/pages/:id, GET} route +0ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG [NestApplication] Nest application successfully started +5ms
[Nest] 1  - 12/01/2022, 1:49:54 PM     LOG Server started! Port: 80

向MSSQL发出请求后立即出错

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: No event 'featureExtAck' in state 'SentLogin7WithNTLMLogin'
    at Connection.dispatchEvent (/usr/src/app/node_modules/tedious/lib/connection.js:1663:26)
    at Parser.<anonymous> (/usr/src/app/node_modules/tedious/lib/connection.js:1224:12)
    at Parser.emit (node:events:513:28)
    at Readable.<anonymous> (/usr/src/app/node_modules/tedious/lib/token/token-stream-parser.js:27:14)
    at Readable.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Readable.push (node:internal/streams/readable:228:10)
    at next (node:internal/streams/from:98:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Readable instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

我真的不知道该怎么处理它,如何调试它,找到问题。任何帮助和建议是感谢。

bqf10yzr

bqf10yzr1#

通过在Dockerfile中更改此代码解决了问题

-COPY ./server/package.json ./server/.env ./
-RUN yarn install --pure-lockfile
+COPY ./server/package.json ./server/yarn.lock ./server/.env ./
+RUN yarn install --production=true --frozen-lockfile

相关问题