Re: [jetty-users] How to use Jetty ProxyServlet for reverse proxying?
Hi, On Tue, Aug 31, 2021 at 5:46 PM Peter Boughton wrote: > > Since BalancerServlet has rewriteTarget implemented, it seems a > workaround would be to use this with a single member. > > I was experimenting with that and found a minor bug: if there are no > members defined it gives a divide by zero error. (I expected something > along the lines of "no balancer members defined"). > > Adding a member via setInitParameter balancerMember.a.proxyTo and it > then starts proxying. > > However, there's a more significant issue: given a servletMapping of > /proxy/* a request to http://localhost:8080/proxy/ is sent to > http://localhost:8081/proxy/ - I expected it would go instead to > http://localhost:8081/ - i.e. that the servletMapping would be removed. > > If the inclusion of servletMapping is deliberate (or can't be fixed > without breaking backwards compatibility), then a parameter to > explicitly exclude it would be useful. > > > Should I add the above as comments to 6678, raise as distinct issue(s), > or something else? Please add as a comment to the existing issue. The issue you raised turned out to be of a larger scope, as the current proxy module is for forward proxies, not reverse proxies. We plan to be more explicit about these modules and document them in Jetty 10. -- Simone Bordet --- Finally, no matter how good the architecture and design are, to deliver bug-free software with optimal performance and reliability, the implementation technique must be flawless. Victoria Livschitz ___ jetty-users mailing list jetty-users@eclipse.org To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
Re: [jetty-users] Migrating 9 to 10: what replaces WebSocketServlet and JSON.parse() ?
Jetty 10 still has the concept of a WebSocketServlet. But it's no longer generic and functions for all implementations/apis. With that said, you appear to be using the Jetty implementation/apis. So, switch to `org.eclipse.jetty.websocket.server.JettyWebSocketServlet` instead. Found in websocket-jetty-server.jar See: https://search.maven.org/search?q=fc:org.eclipse.jetty.websocket.server.JettyWebSocketServlet JSON classes were moved out from jetty-util to jetty-util-ajax back in Jetty 9.0.0 You can find it at `org.eclipse.jetty.util.ajax.JSON` See: https://search.maven.org/search?q=fc:org.eclipse.jetty.util.ajax.JSON Note: that the static method JSON.parse(String) doesn't exist in Jetty 10. The static methods on JSON couldn't handle the various configurations for collections/maps/lists/pojos etc. And the error messages were woefully inadequate as a result. So you'll need to change your usage a small bit. The closest usage would be ... JSON json = new JSON(); // configure json here Map myMap = (Map) json.fromJSON(str); Joakim Erdfelt / joa...@webtide.com On Tue, Aug 31, 2021 at 9:36 AM Alexander Farber wrote: > Hello, > > I am trying to migrate a war servlet from 9.4.43.v20210629 to 10.0.6 and > have read > > https://www.eclipse.org/jetty/documentation/jetty-10/programming-guide/index.html#pg-migration-94-to-10 > > But unfortunately I still have questions - in my servlet I have: > > public class MyServlet extends WebSocketServlet { > @Override > public void configure(WebSocketServletFactory factory) { > mLanguage = System.getenv("COUNTRY"); > mBundle = ResourceBundle.getBundle("strings", > LOCALES.get(mLanguage)); > factory.getPolicy().setIdleTimeout(IDLE_TIMEOUT_SECONDS * 1000); > factory.getPolicy().setMaxBinaryMessageSize(0); > factory.getPolicy().setMaxTextMessageSize(64 * 1024); > factory.register(MyListener.class); > factory.setCreator(new MyCreator(this, > mBundle.getString(STR_DATABASE_URL))); > } > @Override > protected void doGet(HttpServletRequest httpReq, HttpServletResponse > httpResp) throws ServletException, IOException { >// > } > } > > What is the class to use in Jetty 10 instead of WebSocketServlet? > > Also, I use the following code in few spots to parse JSON strings: > > Map myMap = (Map) JSON.parse(str); > > but now I get the compile error: String cannot be converted to Source > > Is there a new parser, should I maybe use AsyncJSON and how? > > Best regards > Alex > > > > ___ > jetty-users mailing list > jetty-users@eclipse.org > To unsubscribe from this list, visit > https://www.eclipse.org/mailman/listinfo/jetty-users > ___ jetty-users mailing list jetty-users@eclipse.org To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
Re: [jetty-users] How to use Jetty ProxyServlet for reverse proxying?
Since BalancerServlet has rewriteTarget implemented, it seems a workaround would be to use this with a single member. I was experimenting with that and found a minor bug: if there are no members defined it gives a divide by zero error. (I expected something along the lines of "no balancer members defined"). Adding a member via setInitParameter balancerMember.a.proxyTo and it then starts proxying. However, there's a more significant issue: given a servletMapping of /proxy/* a request to http://localhost:8080/proxy/ is sent to http://localhost:8081/proxy/ - I expected it would go instead to http://localhost:8081/ - i.e. that the servletMapping would be removed. If the inclusion of servletMapping is deliberate (or can't be fixed without breaking backwards compatibility), then a parameter to explicitly exclude it would be useful. Should I add the above as comments to 6678, raise as distinct issue(s), or something else? ___ jetty-users mailing list jetty-users@eclipse.org To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
[jetty-users] Migrating 9 to 10: what replaces WebSocketServlet and JSON.parse() ?
Hello, I am trying to migrate a war servlet from 9.4.43.v20210629 to 10.0.6 and have read https://www.eclipse.org/jetty/documentation/jetty-10/programming-guide/index.html#pg-migration-94-to-10 But unfortunately I still have questions - in my servlet I have: public class MyServlet extends WebSocketServlet { @Override public void configure(WebSocketServletFactory factory) { mLanguage = System.getenv("COUNTRY"); mBundle = ResourceBundle.getBundle("strings", LOCALES.get(mLanguage)); factory.getPolicy().setIdleTimeout(IDLE_TIMEOUT_SECONDS * 1000); factory.getPolicy().setMaxBinaryMessageSize(0); factory.getPolicy().setMaxTextMessageSize(64 * 1024); factory.register(MyListener.class); factory.setCreator(new MyCreator(this, mBundle.getString(STR_DATABASE_URL))); } @Override protected void doGet(HttpServletRequest httpReq, HttpServletResponse httpResp) throws ServletException, IOException { // } } What is the class to use in Jetty 10 instead of WebSocketServlet? Also, I use the following code in few spots to parse JSON strings: Map myMap = (Map) JSON.parse(str); but now I get the compile error: String cannot be converted to Source Is there a new parser, should I maybe use AsyncJSON and how? Best regards Alex ___ jetty-users mailing list jetty-users@eclipse.org To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users