Websocket im Frühjahr Boot-App - Getting 403Websocket im Frühjahr Boot-App - Getting 403 Forbidden
VerboteneIch kann an die websocket von Client verbinden sockjs/stompjs verwenden, wenn ich dies in Eclipse laufen (keine Feder-Boot).
Aber wenn ich ein Spring boot jar (grodlew build) für den websocket-Code erstellen und java -jar websocket-code.jar ausführen, bekomme ich einen Fehler 403 beim Verbinden mit dem Websocket.
Ich habe keine Authentifizierung für die Websockets. Ich habe einen CORS-Filter und denke, alle Header direkt in Anfrage/Antwort haben.
Unten ist mein build.gradle
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'
}
Update:
Added ein CORS-Filter mit response.setHeader ("Access-Control-Allow-Origin", "http://localhost:8089");
In Firebug auf Client-Seite
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
Herkunft ich aus bin anfordernden ist in der Allow-Origin-Liste. Es wird immer noch die Nachricht "Abgelehnte Anfrage" in den Protokollen angezeigt.
Nicht sicher, ob diese noch funktioniert. Für mich sagt der Web-Socket-Layer Anmeldeinformationen, um wahr zu sein, und auch wenn ich meinen Satz meine Erlaubnis Ursprünge in die CORS setzen. Ich bekomme immer noch eine 403 verboten – numerical25