Comments (3)
@surajbhosale4933 Please update with an app/test case that demonstrate the issue. Please test with the latest version of Atmosphere as you version is really old and unsupported. Re-open one you have it.
from atmosphere.
@jfarcand I tried with update latest version of atmosphere-runtime (2.7.9) and atmosphere-spring(2.6.5), but still facing atmosphere removal issue from framework automatically. Our example is like:
from
Client Side:
uri = serverId+"/sb/test/msg";
Socket socket = getClient().create(options);
socket.on("message", new Function<List>() {
@OverRide
public void on(List messages) {
processMessages(messages);
}
}).on(Event.REOPENED.name(), new Function<List>() {
@OverRide
public void on(List messages) {
processMessages(messages);
}
}).on(new Function() {
@OverRide
public void on(Throwable t) {
if(connected) {
final LinkedHashMap<ReportKey, Object> map = new LinkedHashMap<>();
map.put(ReportKey.URL, uri);
map.put(ReportKey.DATE_TIME, System.currentTimeMillis());
map.put(ReportKey.REASON, t.getMessage());
map.put(ReportKey.CLIENT_ID, clientUuid);
showDisconnectMsg();
}
String authErrorMsg = "401 response received, but no WWW-Authenticate header was present";
if(t.getMessage().contains(authErrorMsg) && needAuth){
// Means auth error from server on reconnecting.
}
connected = Boolean.FALSE;
attachedToServerInfo.setConnected(false);
logger.error("Connection refused by Atmosphere Server exception is " + t);
}
}).on(Event.CLOSE.name(), new Function<String>() {
@Override
public void on(String t) {
logger.trace("Connection closed");
}
}).on(Event.OPEN.name(), new Function<String>() {
@Override
public void on(String t) {
connected = Boolean.TRUE;
final LinkedHashMap<ReportKey, Object> map = new LinkedHashMap<>();
map.put(ReportKey.URL, uri);
map.put(ReportKey.DATE_TIME, System.currentTimeMillis());
map.put(ReportKey.CLIENT_ID, clientUuid);
logger.trace("Connection opened");
infoMessage.setVisible(false);
if (flag) {
flag = Boolean.FALSE;
attachedToServerInfo.setConnected(false);
}
if (!attachedToServerInfo.isConnected()) {
attachedToServerInfo.setConnected(true);
infoMessage.setIsDispose(true);
}
}
}).open(**getRequestBuilder**(uri, this.serverToken).build());
private RequestBuilder getRequestBuilder(String uri, String token) throws Exception {
RequestBuilder request = getClient().newRequestBuilder()
.method(Request.METHOD.GET)
.uri(uri)
.enableProtocol(false)
.trackMessageLength(false)
.header("X-Atmosphere-tracking-id", clientUuid.toString())
.header(RequestManager.HEADER_NAME, token)
.encoder(new Encoder<Message, String>() {
@OverRide
public String encode(Message data) {
try {
return mapper.writeValueAsString(data);
} catch (IOException e) {
logger.error("Error while encoder message " + e.getMessage());
throw new RuntimeException(e);
}
}
})
.decoder(new Decoder<String, List>() {
@OverRide
public List decode(Event type, String data) {
return processStringResponse(type, data);
}
}).transport(Request.TRANSPORT.SSE);
return request;
}
Server Side:
@SBManagedService(path = "/sb/test/msg", atmosphereConfig = {MAX_INACTIVE + "=120000", UUIDBROADCASTERCACHE_CLIENT_IDLETIME + "=120"})
public class AtmosphereController {
}
@target({ElementType.TYPE})
@retention(RetentionPolicy.RUNTIME)
public @interface SBManagedService {
String path() default "/";
public Class<? extends AtmosphereResourceEventListener>[] listeners() default {};
Class<? extends Broadcaster> broadcaster() default DefaultBroadcaster.class;
Class<? extends AtmosphereInterceptor>[] interceptors() default {};
String[] atmosphereConfig() default {};
Class<? extends BroadcasterCache> broadcasterCache() default NewSBBroadcasterCache.class;
Class<? extends BroadcastFilter>[] broadcastFilters() default {};
}
@AtmosphereAnnotation(SBManagedService.class)
public class SBManagedServiceProcessor implements Processor {
private static final Logger logger = LoggerFactory.getLogger(ManagedServiceProcessor.class);
@Override
public void handle(AtmosphereFramework framework, Class<Object> annotatedClass) {
try {
Class<?> aClass = annotatedClass;
SBManagedService a = aClass.getAnnotation(SBManagedService.class);
framework.setBroadcasterCacheClassName(a.broadcasterCache().getName());
List<AtmosphereInterceptor> l = new LinkedList<AtmosphereInterceptor>();
AnnotationUtil.defaultManagedServiceInterceptors(framework, l);
atmosphereConfig(a.atmosphereConfig(), framework);
filters(a.broadcastFilters(), framework);
AtmosphereInterceptor aa = listeners(a.listeners(), framework);
if (aa != null) {
l.add(aa);
}
Object c = framework.newClassInstance(Object.class, aClass);
AtmosphereHandler handler = framework.newClassInstance(ManagedAtmosphereHandler.class,
ManagedAtmosphereHandler.class).configure(framework.getAtmosphereConfig(), c);
framework.filterManipulator(new BroadcasterConfig.FilterManipulator() {
@Override
public Object unwrap(Object o) {
if (o != null && ManagedAtmosphereHandler.Managed.class.isAssignableFrom(o.getClass())) {
o = ManagedAtmosphereHandler.Managed.class.cast(o).object();
}
return o;
}
@Override
public BroadcastFilter.BroadcastAction wrap(BroadcastFilter.BroadcastAction a, boolean wasWrapped) {
if (wasWrapped) {
return new BroadcastFilter.BroadcastAction(a.action(), new ManagedAtmosphereHandler.Managed(a.message()));
} else {
return a;
}
}
});
AnnotationUtil.interceptorsForManagedService(framework, Arrays.asList(a.interceptors()), l);
framework.addAtmosphereHandler(a.path(), handler, broadcaster(framework, a.broadcaster(), a.path()), l);
} catch (Throwable e) {
logger.warn("", e);
}
}
}
Earlier it was long-polling instead of SSE. there was no issue, but with SSE we are facing AtmosphereResource getting removed from framework after some time.
from atmosphere.
@surajbhosale4933 I really need a test case I can run unfortunately in order to help. I have extreme limited time. Hope you understand
from atmosphere.
Related Issues (20)
- Potential Refactoring Estimate HOT 1
- SSE doesn't output error bodies, just spaces
- Compress JSON messages with atmosphere
- Compression websocket messages HOT 8
- Provide runtime hints for Spring Boot 3 native applications HOT 1
- Support atmosphere-spring for Jakarta 3.0 jakarta.servlet HOT 8
- Broadcasters with names that contain both { and } are never cleaned up HOT 1
- Websocket trying to reconnect every 30 seconds HOT 1
- Websocket Closing Connection Again and Again HOT 1
- HTTP/3 WebTransport API
- JDK17 breaks working Atmosphere HOT 1
- Long-polling requests show XML parsing syntax error in Firefox console HOT 1
- "org.atmosphere.container.Jetty9AsyncSupportWithWebSocket" does not exist HOT 1
- Is there any security concerns because of query string in request URI
- NPE in AtmosphereRequestImpl because of race condition HOT 1
- NPE in AtmosphereRequestImpl.wrap
- JSR356Endpoint dropping custom attributes on the HTTP request HOT 8
- Double string length prepended to cached heartbeat messages HOT 2
- Missing handshake session leads to NPE in Jetty HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atmosphere.