Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebBack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem
WebBack
Commits
2f370978
Commit
2f370978
authored
3 months ago
by
심재엽
Browse files
Options
Downloads
Patches
Plain Diff
fix: , 빠진 오류 수정
parent
fb3e1641
No related branches found
Branches containing commit
No related tags found
1 merge request
!43
배포코드 master브랜치로
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wsServer.js
+17
-16
17 additions, 16 deletions
wsServer.js
with
17 additions
and
16 deletions
wsServer.js
+
17
−
16
View file @
2f370978
...
@@ -94,6 +94,7 @@ function startWebSocketServer() {
...
@@ -94,6 +94,7 @@ function startWebSocketServer() {
});
});
server
.
on
(
'
upgrade
'
,
(
req
,
socket
,
head
)
=>
{
server
.
on
(
'
upgrade
'
,
(
req
,
socket
,
head
)
=>
{
console
.
log
(
'
WebSocket 업그레이드 요청 수신:
'
,
req
.
headers
);
handleWebSocketUpgrade
(
req
,
socket
);
handleWebSocketUpgrade
(
req
,
socket
);
});
});
...
@@ -103,22 +104,22 @@ function startWebSocketServer() {
...
@@ -103,22 +104,22 @@ function startWebSocketServer() {
}
}
function
handleWebSocketUpgrade
(
req
,
socket
)
{
function
handleWebSocketUpgrade
(
req
,
socket
)
{
const
key
=
req
.
headers
[
'
sec-websocket-key
'
];
try
{
const
acceptKey
=
generateAcceptValue
(
key
)
;
const
key
=
req
.
headers
[
'
sec-websocket-
key
'
]
;
const
responseHeaders
=
[
const
acceptKey
=
generateAcceptValue
(
key
);
'
HTTP/1.1 101 Switching Protocols
'
,
const
responseHeaders
=
[
'
Upgrade: websocket
'
,
'
HTTP/1.1 101 Switching Protocols
'
,
'
Connection: Upgrade
'
,
'
Upgrade: websocket
'
,
`Sec-WebSocket-Accept:
${
acceptKey
}
`
'
Connection: Upgrade
'
,
`Sec-WebSocket-Accept:
${
acceptKey
}
`
,
`Sec-WebSocket-Accept:
${
acceptKey
}
`
,
`Access-Control-Allow-Origin:
${
FRONT_URL
}
`
,
// 환경변수에서 가져옴
`Access-Control-Allow-Origin:
${
process
.
env
.
FRONT_URL
}
`
,
// 환경변수에서 가져옴
'
Access-Control-Allow-Credentials: true
'
'
Access-Control-Allow-Credentials: true
'
];
];
socket
.
write
(
responseHeaders
.
join
(
'
\r\n
'
)
+
'
\r\n\r\n
'
);
socket
.
write
(
responseHeaders
.
join
(
'
\r\n
'
)
+
'
\r\n\r\n
'
);
clients
.
push
(
socket
);
}
catch
(
error
)
{
// 클라이언트를 clients 배열에 추가
console
.
error
(
'
WebSocket 업그레이드 실패:
'
,
error
);
clients
.
push
(
socket
);
}
socket
.
on
(
'
data
'
,
async
buffer
=>
{
socket
.
on
(
'
data
'
,
async
buffer
=>
{
try
{
try
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment