- 필요 라이브러리
- rn-fetch-blob
- react-native 에 fetch 가 내장되어 있으나 blob 형태로 가져올수 없어 자동 convert 중 utf-8 로 변경 됨.
blob 으로 화면단까지 가져와 처리할수 있도록 해당 라이브러리 사용. - yarn add rn-fetch-blob
- iconv-lite
- charset converter. 유명한 그것.
- yarn add iconv-lite
- buffer
- 변환 과정에서 buffer 에 담아 변환을 하는데 브라우저에는 내장되어 있으나 react-native 에는 없음.
이전 작업할때 기억에는 debug 모드로 브라우져 연동시 있는것으로 간주하고 작동 했던 것으로 기억 함.
하지만 debug 모드 끄면 없다고 오류 뱉음. - yarn add buffer
- base-64
- base64 encode decode 그것. rn-fetch-blob 의 data 가 base64 로 넘어옴
- yarn add base-64
- 코드
- request
1 2 3 4 5 6 7 8 9
makeQuery(obj) { var str = []; for (var p in obj) if (obj.hasOwnProperty(p)) { // str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); str.push(escape(iconv.encode(p, 'EUC-KR').toString('binary')) + "=" + escape(iconv.encode(obj[p], 'EUC-KR').toString('binary'))); } return str.join("&"); }
- response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
RNFetchBlob.fetch('POST', this.url, { 'Content-Type': 'application/x-www-form-urlencoded' , 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36' } , this.makeQuery(param) ) .then((response) => { if(response.info().status != 200){ throw new Error('status error'); } let base64Decode = base64.decode(response.data); let byteArray = new Uint8Array(base64Decode.length); for (var i = 0; i < base64Decode.length; i++) { byteArray[i] = base64Decode.codePointAt(i); } let decodedString = iconv.decode(byteArray, 'EUC-KR').toString(); return decodedString; }) }
2019년 9월 30일 월요일
react-native EUC-KR UTF-8 convert
react-native 에서 EUC-KR UTF-8 Convert 에 대해 설명 한다.
2019년 9월 29일 일요일
react-native 초기 설정 정리
react-native 을 사용하며 공통으로 적용해야 할 내용들에 대해서 정리를 해본다.
- react-navigation
- 설명 : 명칭 그대로 react 의 navigation 을 위한 모듈.
- 단순 사용시 설치 package
yarn add react-navigation
yarn add react-native-gesture-handler - Tab 사용시 추가 설치 package
yarn add react-navigation-stack - react-native-firebase
- 설명 : firebase 모듈
- 선행
- 패키지 명 변경 : https://stackoverflow.com/questions/37389905/change-package-name-for-android-in-react-native?answertab=active#tab-top
- firebase 프로젝트 등록 및 필수 파일 다운로드 : https://rnfirebase.io/docs/v5.x.x/installation/initial-setup - package 설치
yarn add react-native-firebase
2019년 9월 5일 목요일
tiles3 주의사항
definition 설정 중
wild 카드 사용시 순서 및 설정 법에 대하여 항상 잊는 것 같아 기록 함.
- wild 카드 사용
1. 컨트롤러
return "/test/abcd";
2. tiles 설정파일
<definition name="/test/*" template="/WEB-INF/tiles/layout/print.jsp">
<put-attribute name="body" value="/WEB-INF/jsp/{0}.jsp" />
</definition>
위에서 name 의 test 는 호출하는 controller 의 requestMapping 과는 무관하다.
단순히 return 하는 jsp 파일의 경로 순서의 패턴을 가리키며
put-attribute 의 {0} 도 사용한 wild 카드의 순서를 가리킨다.
- 설정 파일 순차 적용
설정파일을 위에서 부터 읽다가 부합하는 조건이 있으면 xml 하단까지 안가고 해당 설정을 적용 한다.
wild 카드 사용시 순서 및 설정 법에 대하여 항상 잊는 것 같아 기록 함.
- wild 카드 사용
1. 컨트롤러
return "/test/abcd";
2. tiles 설정파일
<definition name="/test/*" template="/WEB-INF/tiles/layout/print.jsp">
<put-attribute name="body" value="/WEB-INF/jsp/{0}.jsp" />
</definition>
위에서 name 의 test 는 호출하는 controller 의 requestMapping 과는 무관하다.
단순히 return 하는 jsp 파일의 경로 순서의 패턴을 가리키며
put-attribute 의 {0} 도 사용한 wild 카드의 순서를 가리킨다.
- 설정 파일 순차 적용
설정파일을 위에서 부터 읽다가 부합하는 조건이 있으면 xml 하단까지 안가고 해당 설정을 적용 한다.
2019년 8월 27일 화요일
@Retryable
Transaction 처리 중 org.hibernate.exception.LockAcquisitionException 발생 하여 처리 한 내용.
- 상황
- 1개 이상의 Thread 에서 동일한 테이블에 데이터 유무 확인하여 insert 하기 위해 read -> 데이터 유무 체크 -> insert 하는 method 에 Transaction 설정. 이때 'Phantom Read' 발생을 막기 위해 Isolation 은 SERIALIZABLE 로 설정 함.
- 12 개의 Thread 로 구동 중 JPA 에서 org.hibernate.exception.LockAcquisitionException 발생. 확인 해보니 이미 Lock 이 걸려 있는데 다른 thread 에서 Lock 획득 하려다가 발생한 Exception 으로 확인하고 처리.
- 처리
- 구글링 해보니 retry 하라는 내용이 많은것으로 보아 retry 로 처리 예정. 아직 안해봄. ㅋ
- Spring-retry 가 처리 방안으로 보임
- 참고
@Transactional @Caching 사용시 주의 사항
Spring 에서 @Transactional @Caching 등
Spring AOP(Proxy) 관련 기능 사용중 발생한 문제 처리 중 습득한 지식이다.
Spring AOP(Proxy) 관련 기능 사용중 발생한 문제 처리 중 습득한 지식이다.
- spring aop 의 proxy 종류
- JDK Proxy
- Interface 를 구현한 경우
- CGLIB
- Interface 없이 Class 로 구현한 경우
- Spring 의 기본 사항
- 외부에서 Invocation (호출) 한 method 에만 Proxy 기능 작동
- public method 에만 Proxy 기능 작동
- Self-Invocation (Object 내에서 내부 method 호출) 시 Proxy 기능 작동 안함.
- 처리 방법
- AspectJ 사용
- Spring AOP 의 Weaving 방식을 AspectJ 의 Weaving 방식으로 변경 함으로서 처리함.
- Self-Invocation 시 직접 method 호출이 아닌 자신의 bean 을 사용하여 method 호출
- 가장 간단 하지만 private method 호출 불가
- ex)
- @Autowired
- private SomeObject self;
- self.someMethod();
- 참고 사이트
2019년 7월 22일 월요일
IBM websphere 설치 방법
- 작성 일자 : 2019-07-23
- 목적 : eclipse 에서 websphere 설치 및 구동
- 요약 :
- eclipse plugin 설치
- IBM Installation Manager 설치
- IBM Websphere repository 등록하여 설치
- 안내 :
- IBM 사이트를 뒤져봤는데 websphere 8.5 를 직접 다운로드 하는 링크는 없어진듯 하다. IBM Installation Manager 를 통한 repository 설치만 지원 하는것 같음.
- 설치 :
- Eclipse Plugin
- IBM 의 플러그인 설명에 보면 Oxygen 이상만 가능하다고 함.
- Eclipse MarketPlace 에서 websphere 검색하면 Developer Tools 가 버전별로 나옴. 맞는 플러그인 설치
- IBM Installation Manager
- IBM Websphere 8.5 repository
- https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.installation.base.doc/ae/cins_repositories.html
- 인스톨 후 IBM Installation Manager 실행
- 파일 -> 환경설정 -> 저장소 선택
- 저장소 추가 (아래 이미지 우측의 repository 주소 입력 및 IBM 계정 입력)
- 확인 클릭
- IBM Installation Manager 바탕화면의 설치 클릭
- 추가한 repository 의 설치 파일 클릭 및 설치 실행
- Eclipse 에서 server add 시 websphere 선택 후 설치 위치 선택
- C:\Program Files (x86)\IBM\WebSphere OR C:\Program Files (x86)\IBM\IMShared 일 것으로 보임
- 설치 후 Eclipse 에서 연동 아직 안해 봄.
설치 중 Installation Manager 에 Websphere repository 등록 후 developer 버전 설치 하려는 도중 권한 없음 문제가 발생 되었다.
- IBM developer 사이트에 회원가입
- Installation Manager 1.8.9 -> 1.9.0 업데이터
등을 시도 하였으나 불가능...
그냥 trial 버전으로 설치 함.
developer 버전 설치 할수 있는 권한이 필요해 보이는데 어떻게 해야 하지??
2019년 7월 14일 일요일
ubuntu coturn apt-get install
Coturn is an open source TURN and STUN server for VoIP and WebRTC.
Update the system and install Coturn
apt-get update && apt-get install coturn
Edit turnserver config
vi /etc/turnserver.conf
listening-port=3478 cli-port=5766 listening-ip=172.17.19.101
Create a turn secret
- either
xxd -ps -l 32 -c 32 /dev/random - or
openssl rand -hex 32
583bAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFF
Add it to TURN REST API flag section
# This allows TURN credentials to be accounted for a specific user id. # If you don't have a suitable id, the timestamp alone can be used. # This option is just turning on secret-based authentication. # The actual value of the secret is defined either by option static-auth-secret, # or can be found in the turn_secret table in the database (see below). # use-auth-secret # 'Static' authentication secret value (a string) for TURN REST API only. # If not set, then the turn server # will try to use the 'dynamic' value in turn_secret table # in user database (if present). The database-stored value can be changed on-the-fly # by a separate program, so this is why that other mode is 'dynamic'. # static-auth-secret=583bAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFF
Add Coturn ports to services
vi /etc/services
stun-turn 3478/tcp # Coturn stun-turn 3478/udp # Coturn stun-turn-tls 5349/tcp # Coturn stun-turn-tls 5349/udp # Coturn turnserver-cli 5766/tcp # Coturn
Open ports 3478 and 5349 in the firewall.
Start Coturn server as daemon
vi /etc/default/coturn
# Uncomment it if you want to have the turnserver running as
# an automatic system service daemon
#
TURNSERVER_ENABLED=1
turnserver -o -v
==== Show him the instruments, Practical Frost: ==== 0: TLS supported 0: DTLS supported 0: DTLS 1.2 supported 0: TURN/STUN ALPN supported 0: Third-party authorization (oAuth) supported 0: GCM (AEAD) supported 0: OpenSSL compile-time version: OpenSSL 1.0.2g-fips 1 Mar 2016 0: 0: SQLite supported, default database location is /var/lib/turn/turndb 0: Redis supported 0: PostgreSQL supported 0: MySQL supported 0: MongoDB is not supported 0: 0: Default Net Engine version: 3 (UDP thread per CPU core) =====================================================
netstat -npta | grep turnserver
tcp 0 0 127.0.0.1:5766 0.0.0.0:* LISTEN 19039/turnserver tcp 0 0 172.17.19.101:3478 0.0.0.0:* LISTEN 19039/turnserver
turnserver -h turnadmin -h
service coturn stop service coturn start service coturn restart service coturn status
● coturn.service - LSB: coturn TURN Server Loaded: loaded (/etc/init.d/coturn; bad; vendor preset: enabled) Active: active (running) since Mon 2018-05-07 01:26:56 CEST; 3s ago Docs: man:systemd-sysv-generator(8) Process: 14464 ExecStop=/etc/init.d/coturn stop (code=exited, status=0/SUCCESS) Process: 14516 ExecStart=/etc/init.d/coturn start (code=exited, status=0/SUCCESS) Tasks: 7 Memory: 4.4M CPU: 52ms CGroup: /system.slice/coturn.service └─14526 /usr/bin/turnserver -c /etc/turnserver.conf -o -v
Add to DNS
turn.domain.xx → domain.xx stun.domain.xx → domain.xx
Coturn CLI
telnet localhost 5766
Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. TURN Server Coturn-4.5.0.3 'dan Eider' Type '?' for help >
Coturn webadmin interface
Create admin user
turnadmin -A -u admin -p verysecretpassword
Login to
https://domain.xx:3478
피드 구독하기:
덧글 (Atom)


