Bad Set-Cookie header: 관련되어 문의를 드립니다.

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
안녕하세요.

문의사항이 있어서 글을 남기게 되었습니다.

현재 상황은 헤더에 값을 담아서 보내면 조회가 되도록 하려고 하는중이었는데..

POST- MAN으로는 GET방식으로 조회가 되는 상태입니다.

하지만, ngrinder에서 헤더에 값을 넣어서 전송을하면 아래 에러로그가 계속 출력이 되어서요...

혹시 몰라서 해당 소스도 같이 업로드를 드립니다 .

소스에 문제가 있는지 혹시 해결할 수 있는 팁을 알려주시면 프로젝트에 적용을해보겠습니다!

감사합니다 ㅜ

[ 에러로그 ]
java.net.ProtocolException: Bad Set-Cookie header: SCOUTER=스카우터값; Expires=Sat, 26-Feb-2089 03:22:40 GMT; Path=/;,Secure, SCOUTER=스카우터값; Expires=Sat, 26-Feb-2089 03:22:41 GMT; Path=/;,Secure, JSESSIONID=JSESSIONID값; Path=/프로젝트명; Secure;,HttpOnly;Secure
No '=' found for token starting at position 224





[적용소스]
import static net.grinder.script.Grinder.grinder
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
import net.grinder.plugin.http.HTTPRequest
import net.grinder.plugin.http.HTTPPluginControl
import net.grinder.script.GTest
import net.grinder.script.Grinder
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
// import static net.grinder.util.GrinderUtils.* // You can use this if you're using nGrinder after 3.2.3
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith

import java.util.Date
import java.util.List
import java.util.ArrayList

import HTTPClient.Cookie
import HTTPClient.CookieModule
import HTTPClient.HTTPResponse
import HTTPClient.NVPair

/**
 * A simple example using the HTTP plugin that shows the retrieval of a
 * single page via HTTP.
 *
 * This script is automatically generated by ngrinder.
 *
 * @author admin
 */
@RunWith(GrinderRunner)
class TestRunner {

        public static GTest test
        public static HTTPRequest request
        public static NVPair[] headers = []
        public static NVPair[] params = []
        public static Cookie[] cookies = []
        public static Date date
        public static Cookie cookie
       

        @BeforeProcess
        public static void beforeProcess() {
                HTTPPluginControl.getConnectionDefaults().timeout = 600000
                test = new GTest(1, "도메인")
                request = new HTTPRequest()
                grinder.logger.info("테스트시작");
                List<NVPair> headerList = new ArrayList<>()
                headerList.add(new NVPair("Content-Type","application/json;charset=utf-8"))
                headerList.add(new NVPair("키","밸류"))
                headerList.add(new NVPair("키","밸류"))
                headerList.add(new NVPair("키","밸류"))
                headerList.add(new NVPair("키","밸류"))
                headerList.add(new NVPair("키","밸류"))
                headerList.add(new NVPair("키","밸류"))
                headerList.add(new NVPair("키","밸류"))
                headers = headerList.toArray()
               
                List<Cookie> cookieList = new ArrayList<Cookie>()
                cookieList.add(new Cookie("SCOUTER","z7hrpb22n4rj2v","도메인","/",new Date(),false))
                cookies = cookieList.toArray()
               
                grinder.logger.info("COOKIE_LIST"+cookies.toString());
                grinder.logger.info("HEADER_LIST"+headers.toString());
                grinder.logger.info("테스트종료")
                grinder.logger.info("before process.");
        }
        @BeforeThread
        public void beforeThread() {
                test.record(this, "test")
                grinder.statistics.delayReports=true;
                grinder.logger.info("before thread.");
        }

        @Before
        public void before() {
                request.setHeaders(headers)
                cookies.each { CookieModule.addCookie(it, HTTPPluginControl.getThreadHTTPClientContext()) }
                grinder.logger.info("before. init headers and cookies");
        }
        @Test
        public void test(){
        try{
                HTTPResponse result = request.GET("https://도메인/프로젝트명/mobile/user/inform/confirm")
        }catch(Exception e){
                grinder.logger.error("ERROR_OCCURED"+e.toString());
                fail();
        }
               
               
                if (result.statusCode == 301 || result.statusCode == 302) {
                        grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode);
                } else {
                        assertThat(result.statusCode, is(200));
                }
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

leedonggyu
Administrator
안녕하세요.

아래 오류와 연관 있어 보이는데요.
https://github.com/cossme/grinder/issues/28

서버에서 리턴해주는 response 'Set-Cookie' 해더를 파싱하는 과정에서 문제가 있는 것 같습니다.
서버 response를 테스트시에만 임시로 수정하여 테스트 하시거나, 단순 TPS 측정만 하셔도 문제 없으시면
https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient 라이브러리를 추가하셔서 해당 컴포넌트로 테스트 진행해 주시면 될 것 같습니다.
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
leedonggyu님 안녕하세요!
상세하게 안내 및 답변해주셔서 감사합니다.

[추가문의사항1]
혹시 아래의 안내해주신 라이브러리의 경우에는 ngrinder 스크립터 작성시에 import만 해주어도 바로
사용이 가능한지 아니면 다른 작업이 필요한지 궁금합니다.
https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient


알려주신 response부분의 set-cookie 관련되어서 적용 후 후기도 남기겠습니다.


감사합니다!


Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

leedonggyu
Administrator
안녕하세요.

net.grinder.plugin.http.* 대신 해당 라이브러리 import 하시고 바로 사용하시면 될 것 같습니다.
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
안녕하세요!
leedonggyu님 답변해주셔서 감사합니다.

[현재상태]

1. script 메뉴에서 /lib/ 폴더안에 httpclient-4.5.13.jar을 넣고
groovy script에서 상단에 import org.apache.http.impl.client.HttpClient 을 하려고 했는데 인식이 안되어서요
혹시 여기서 제가 놓친 부분이 있을까요??;;

[에러메시지]
C:\Users\desktopboy\.ngrinder_agent\file-store\admin\current\new0208_version.groovy: 11: unable to resolve class org.apache.http.impl.client.HttpClient
 @ line 11, column 1.
   import org.apache.http.impl.client.HttpClient
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

leedonggyu
Administrator
안녕하세요.

https://hc.apache.org/httpcomponents-client-4.5.x/httpclient/examples/org/apache/http/examples/client/ClientWithResponseHandler.java

위 공식 Example을 보니 패키지가
'import org.apache.http.impl.client.HttpClients;' 인 것 같은데요. HttpClients에서 's' 가 빠지신게 아닌가 싶습니다.
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
안녕하세요!leedonggyu님

s붙이니 바로 해결되었습니다. 알려주셔서 감사합니다.
나머지 알려주신부분도 적용후에 다시 문의드리겠습니다.

빠른지원해주셔서 감사합니다!
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
In reply to this post by leedonggyu
안녕하세요.leedonggyu님!

먼저,지원 감사합니다...

현재 알려주신 방법으로 진행중에 문의사항이 하나 더 생겨서요..

저희쪽에서 작성한 코드중에 EntityUtils를 사용하는데 찾아보니

httpccore-4.4.3.jar 파일에 있는 Utils이더라구요..

그런대 해당 코드를 사용하려고 작성한 뒤에 실행을 하면 아래와 같은 메시지가 출력됩니다.

[에러메시지]
2021-02-08 17:28:30,728 ERROR No such property: EntityUtils for class: TestRunner
groovy.lang.MissingPropertyException: No such property: EntityUtils for class: TestRunner
        at TestRunner.HttpClientJson(GET_JSON_HTTPCLIENT.groovy:188)
        at TestRunner$HttpClientJson.callCurrent(Unknown Source)
        at TestRunner.test(GET_JSON_HTTPCLIENT.groovy:227)
        at net.grinder.scriptengine.groovy.junit.GrinderRunner.run(GrinderRunner.java:172)
        at net.grinder.scriptengine.groovy.GroovyScriptEngine$GroovyWorkerRunnable.run(GroovyScriptEngine.java:147)
        at net.grinder.engine.process.GrinderThread.run(GrinderThread.java:118)

[문의사항]

EntityUrils의 경우에는 httpcore-4.4.3.jar 파일을 import 하면 될 줄 알았는데 실행하면
ERROR No such property: EntityUtils for class 라구 출력이 되고 있어서 문의를 드립니다.
추가적으로 제가 취할 수 있는 방법과 힌트를 안내해주시면 실행하겠습니다..


감사합니다.
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

leedonggyu
Administrator
httpclient에 transitive dependency 들이 있는것 같은데요.
https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.13

lib폴더에 jar로 dependency들을 추가하지 마시고, 스크립트를 gradle-groovy 프로젝트로 만드신 후 build.gradle에
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13' 를 추가 하신 후 진행하시는 편이 좋을 것 같습니다.

위 방법으로 한번 진행해 보실수 있으신가요?

Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
leedonggyu님 감사합니다.

해당 알려주신 부분 적용후에 다시 결과를 말씀드리겠습니다!

빠른 답변 감사합니다 leedonggyu님

좋은하루되세요!
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
In reply to this post by leedonggyu
leedonggyu님 안녕하세요!

혹시 스크립트를 gradle-groovy 프로젝트로 만든 후 build.gradle으로 생성하고나서

1번) ngrinder 페이지(http://127.0.0.1:8080/) 테스트 스크립트를 실행
-> 이 경우에는 실행하면 아래와 같은 메시지가 출력되었습니다.

[ build.gradle 파일에 추가한 부분]
compile group : 'org.apache.httpcomponents', name: 'httpclient',version:'4.5.13'

[에러메시지]
Dependencies copy in last_groovy/build.gradle is failed.

2번) 따로 eclipse에 프로젝트를 SVN을 통해서 가져와서 실행

위의 두가지 경우중 어떤걸로 진행해야하는지 궁금합니다!

만약에 2번인 경우 혹시 추천해주실만한 링크도 부탁드리겠습니다 ㅜ


Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

leedonggyu
Administrator
안녕하세요.

1. gradle을 path에 등록했는지 혹은, GRADLE_HOME 환경변수로 gradle home이 지정됐는지 확인해 주세요.(둘 중 하나만 돼있으면 됩니다)
2. .ngrinder 아래에 init.gradle 파일이 아래의 내용을 포함하고 있는지 확인해 주세요.


allprojects {
    apply plugin: "java"

    task __copyDependencies(type: Copy) {
        from configurations.default
        into project.hasProperty("outputDirectory") ? outputDirectory : "lib"
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
안녕하세요! leedonggyu님

도움주셨던 부분으로하여 정상적으로 작동되는 것을 확인했습니다.

지원해주셔서 감사합닌다.

혹시 한가지 더 문의드릴 사항이 생겼는데요..

저희가 서버가 총 7대를 운영하고 있는데 해당 서버에서 테스트를 진행하려고하는 과정에서

[ Test Configuration ] 메뉴에서 Target Server 부분에 아래와 같이 입력했습니다.

입력한 내용 : superman.co.kr:10.2.111.111

위의 처럼 입력해서 사용했습니다.

만약에 한 도메인에  7대 서버를 대상으로 테스트를 진행할 경우에 Target Server에
아래와 같이 입력하는게 맞는지 궁금합니다.

[ 입력할 내용 ]
superman.co.kr:10.2.111.111
superman.co.kr:10.2.111.112
superman.co.kr:10.2.111.113
superman.co.kr:10.2.111.114
superman.co.kr:10.2.111.115
superman.co.kr:10.2.111.116
superman.co.kr:10.2.111.117

아니면

superman.co.kr 이렇게 단일한 도메인만 넣는지 궁금합니다.

긴글 읽고 지원해주셔서 감사합니다.

Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

leedonggyu
Administrator
저건 custom dns 설정이나, 서버에 모니터를 설치해서 서버 상태를 체크할때 필요한건데요.
그냥 해당 도메인으로 request 하실때는 '테스트 대상 서버' 설정을 하지 마시고(전부 삭제) 테스트 해주시면 됩니다.

> superman.co.kr:10.2.111.111 이렇게 설정하시면 마치 로컬 hosts 파일을 수정하신것 처럼 동작하게 됩니다.
Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
빠른 회신 감사합니다 leedonggyu님

> superman.co.kr:10.2.111.111 이렇게 설정하시면 마치 로컬 hosts 파일을 수정하신것 처럼 동작하게 됩니다.

현재 superman.co.kr:10.2.111.111  target server 설정을 안하면 호출이 제대로 되지 않습니다.

지금 httpclient를 사용해서 서버에 호출을 하구 있는데

 superman.co.kr:10.2.111.111 이렇게 설정하시면 마치 로컬 hosts 파일을 수정해도

소스상에서 호출하는 uri부분이 아래와 같으면  

현재 superman.co.kr:10.2.111.111과 상관없이 소스상에서 호출하는 URI 아래에 있는 주소로

https://superman.co.kr/프로젝트명/기타주소 

호출되는 것 같습니다.

소스상에서 호출하는 uri부분으로 호출하는 경우  1도메인에 7대서버로 나뉘어져서 호출하게 되는것인지 궁금합니다.

현재 서버에 모니터링 도구인 스카우터가 설치된 상태입니다.

[ 결론 문의사항 ]

현재 httpclient 호출방식사용하구있습니다~~!
Target Server를 superman.co.kr:10.2.111.111 입력해도 테스트 스크립트상에서
호출하는 부분이 https://superman.co.kr/프로젝트명/기타주소 이면
superman.co.kr 도메인에 포함되어있는 7대 서버로 알아서 호출 가능하게되는지에 관한 여부입니다.

제가 너무 주저리 쓴 것같아 죄송합니다...



Reply | Threaded
Open this post in threaded view
|

Re: Bad Set-Cookie header: 관련되어 문의를 드립니다.

joonpark
In reply to this post by joonpark
안녕하세요!

문의사항이 생겨서 다시 문의글을 남깁니다.

현재 테스트를 잘 되어지구 있는데

다른분의 자리에서 컴퓨터에서 에이전트를 실행하면 아래와 같은 메시지가 출력되어서요..

검색해보았는데 해결방하안녕하세요!

문의사항이 생겨서 다시 문의글을 남깁니다.

현재 테스트를 잘 되어지구 있는데

다른분의 자리에서 컴퓨터에서 에이전트를 실행하면 아래와 같은 메시지가 출력되어서요..

검색해보았는데 해결방법이 나오지 않아서 요청을 드립니다.

메시지는 아래와 같습니다!ㅎㅎ

[상황]
다른분의 자리에서 에이전트 실행시에 아래와 같은 메시지로 인해서 ngrinder에서 agent가 활성화 되어지지 않는현상

[에러메시지]
rfRawData_PerfOS_Processor WHERE Name="_Total"
WARN  oshi.util.platform.wception: Invalid Query: SELECT PERCENTDPCTIME,PERC
rfRawData_PerfOS_Processor WHERE Name="_Total"