のWebSocketを取得します。のWebSocket - 私は日食(なし春ブーツ)でこれを実行すると、私はsockjs/stompjsを使用してクライアントからのWebSocketに接続することができます403禁止</p> <p>を取得する - 春ブーツアプリで403禁止
しかし、websocketコード用のSpringブートjar(gradlew build)を作成し、java -jar websocket-code.jarを実行すると、websocketに接続する際に403エラーが発生します。
私はウェブソケットの認証がありません。 私はCORSフィルタを持っており、リクエスト/レスポンスですべてのヘッダーが正しいと思っています。以下は
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'
sourceCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
}
dependencies {
compile "org.springframework:spring-web:$spring_version"
compile "org.springframework:spring-webmvc:$spring_version"
compile "org.springframework:spring-websocket:$spring_version"
compile "org.springframework:spring-messaging:$spring_version"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework.boot:spring-boot-starter-web"
compile "com.fasterxml.jackson.core:jackson-databind:2.6.2"
compile "com.fasterxml.jackson.core:jackson-core:2.6.2"
compile "com.fasterxml.jackson.core:jackson-annotations:2.6.2"
compile "org.springframework.amqp:spring-rabbit:1.3.5.RELEASE"
compile("org.springframework:spring-tx")
compile("org.springframework.boot:spring-boot-starter-web:1.2.6.RELEASE")
compile("org.springframework.boot:spring-boot-starter-jetty:1.2.6.RELEASE")
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile "org.springframework:spring-test:$spring_version"
}
task wrapper(type: Wrapper) {
gradleVersion = '2.5'
}
更新私のbuild.gradleです:
は response.setHeader( "アクセス制御 - 許可 - 起源"、 "http://localhost:8089")でCORSフィルターを追加しました。放火犯で
クライアント側のIから要求しています
Request Headers
Origin
http://localhost:8089
Response Headers
Access-Control-Allow-Origin
http://localhost:8089
Server Logs
2015-10-02 16:57:31.372 DEBUG 1848 --- [qtp374030679-14] o.s.w.s.s.t.h.DefaultSockJsService : Request rejected, Origin header value http://localhost:8089 not allowed
起源を許可原産のリストです。依然としてログにRequest Rejectedメッセージが表示されます。
これがまだ動作しているかどうかは不明です。私にとっては、Webソケットレイヤーは、証明書が真であることを要求し、CORSに自分のセットを許可しても許可します。私はまだ403が禁じられている – numerical25