BE

Image Entity 추가. Requests(요청) 에 여러 장의 이미지 저장이 필요해서 추가되었습니다.
카테고리 대분류 추가. (일단 컴퓨터/디지털/가전/가구/기타 로 고정.)
Request(요청)
이번 주 한 일
팀 전체 (리더님께서 필두로 정리해 주세요.)
FE
BE
팀원 개인별로 작성해 주세요.
FE
박성인
권구민
BE
신경연
나도관
김유영
FE
import React, { useEffect } from 'react';
import styled, { css } from 'styled-components';
import { getCookie } from '../../utils/cookie';
import { EventSourcePolyfill, NativeEventSource } from 'event-source-polyfill';
const EventSource = EventSourcePolyfill;
export default function AdminDashBoard() {
const dispatch = useDispatch();
const { getDashboard, isDashboardError } = useSelector(
state => state.dashboardStatus.dashboardStatus
);
const fetchSse = async () => {
const url = `${process.env.REACT_APP_SERVER_URL}/api/subscribe`;
const token = getCookie('myToken');
console.log(token);
const eventSource = new EventSource(url, {
headers: {
Authorization: `Bearer ${token}`,
},
// withCredentials: true,
});
eventSource.onopen = async event => {
console.log(event);
console.log('connection opened');
};
eventSource.onmessage = async event => {
console.log('result', event.data);
};
//에러가 발생했습니다.
eventSource.onerror = async event => {
console.log(event);
if (event.target.readyState === EventSource.CLOSED) {
console.log('eventsource closed (' + event.target.readyState + ')');
} else {
console.log('eventsource error', event);
}
// eventSource.close();
};
return eventSource;
};
useEffect(() => {
let eventSource;
const connectSse = async () => {
eventSource = await fetchSse();
};
connectSse();
return () => {
if (eventSource) {
eventSource.close();
}
};
}, []);
//... 생략
return (
<>
//...생략
</>
);
}
BE
나도관
실시간 알림 기능 구현을 위해서 SSE를 사용했습니다.
프론트에서 EventSource를 사용해서 서버로 구독 요청을 보냈는데, 서버 쪽에서 이벤트 스트림을 생성하고, 503에러를 방지하기 위해 더미 데이터를 보냈는데, 프론트 측에서 수신이 되지 않다가 만료되어 에러가 발생합니다.
서버 쪽에서는 에러가 확인되질 않아서 원인 파악이 어려운 상태입니다.
기술적인 도움이 필요합니다.