Coder Social home page Coder Social logo

spring-flights's People

Contributors

bclozel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-flights's Issues

Clarity regarding how to send requests from Server -> rsocket-js client(s)

I am trying to replicate the logic you used to update all connected clients using rsocket-js as the client and spring boot starter rsocket as the server... I cannot seem to do it. I replicated your exact configuration from this project. All my Server -> Client(s) calls are ignored and/or fail silently... not sure where the error is in the stack nor can I find another example on the web that demonstrates how to make calls from Spring boot rsocket server -> rsocket-js client other than this one. I have a few questions:

Does the rsocket-js client responder need any additional configuration to the rsocket-js client (or spring boot rsocket starter server) other than passing in a responder: new ResponderHandler(...) during rsocket-js client initialization? Any advice on how to troubleshoot further would be greatly appreciated.

responder logic for rsocket-js

class ResponderHandler{

    fireAndForget(payload) {
        if(payload.metadata.get(Metadata.ROUTE) == "my-message") {
            const p = payload.data;
            //do something, anything!, complain about metadataType... just don't fail silently :(
        }
    }
    
}

Calling this method inside the controller



	private Mono<Void> testFirstAndForget(RSocketRequester requester) {
		Map<String, String> metadata = Collections.singletonMap("route", "my-message");
		return requester.metadata(metadata, JsonMetadataStrategiesCustomizer.METADATA_MIME_TYPE).data("test").send();
	}

Custom JsonMetadataStraegiesCustomizer

@Component
public class JsonMetadataStrategiesCustomizer implements RSocketStrategiesCustomizer {

	public static final MimeType METADATA_MIME_TYPE = MimeType.valueOf("application/vnd.spring.rsocket.metadata+json");

	private static final ParameterizedTypeReference<Map<String, String>> METADATA_TYPE =
			new ParameterizedTypeReference<Map<String, String>>() {};

	@Override
	public void customize(RSocketStrategies.Builder strategies) {
		strategies.metadataExtractorRegistry(registry -> {
			registry.metadataToExtract(METADATA_MIME_TYPE, METADATA_TYPE, (in, map) -> {
				map.putAll(in);
			});
		});
	}

}

Undo metadata workaround in flight-client

We've introduced a temporary workaround in eb8ad0a to manually encode the routing metadata with the expected format.

Once the rsocket-js library has been updated to support composite metadata, we should be able to undo that workaround and possibly add other metadata, such as security-related information.

Fix rsocket-cli instructions

Due to RSocket metadata changes, the current rsocket-cli version (1.15.0) is out of date and calls result with:

java.lang.IndexOutOfBoundsException: readerIndex(1) + length(108) exceeds writerIndex(20): AbstractPooledDerivedByteBuf$PooledNonRetainedSlicedByteBuf(ridx: 1, widx: 20, cap: 20/20, unwrapped: PooledUnsafeDirectByteBuf(ridx: 128, widx: 128, cap: 1024))
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1451)

See rsocket/rsocket-cli#77 and rsocket/rsocket-cli#76

Adding CORS configuration

Hi Brian

Many thanks for the sample project - very helpful in learning how to use RSockets.

How do I add CORS configuration - lets say to the Radars Controller to restrict the requests to come from an allowed origins ?

I tried @CrossOrigin and it does not work and I also tried adding the following but does not work. If RSocket via websockets doesnt support CORS configuration then it would be harder for security sensitive applications from adopting rsocket.

@Bean
CorsConfigurationSource corsConfiguration() {
CorsConfiguration corsConfig = new CorsConfiguration();
corsConfig.applyPermitDefaultValues();
corsConfig.addAllowedMethod(HttpMethod.PUT);
corsConfig.addAllowedMethod(HttpMethod.DELETE);
corsConfig.setAllowedOrigins(Arrays.asList(FRONTEND_LOCALHOST, FRONTEND_STAGING));
UrlBasedCorsConfigurationSource source =
new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfig);
return source;
}

@Bean
CorsWebFilter corsWebFilter() {
    CorsConfiguration corsConfig = new CorsConfiguration();
    corsConfig.setAllowedOrigins(Arrays.asList("http://allowed-origin.com"));
    corsConfig.setMaxAge(8000L);
    corsConfig.addAllowedMethod("PUT");
    corsConfig.addAllowedHeader("Baeldung-Allowed");

    UrlBasedCorsConfigurationSource source =
            new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/**", corsConfig);

    return new CorsWebFilter(source);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.