---
title: "Routers"
url: https://docs.zeroc.com/ice/3.8/runtime/invocation/routers
language: ruby
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Routers

Programming language: Ruby. Other languages: [C++](https://docs.zeroc.com/ice/3.8/runtime/invocation/routers/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/runtime/invocation/routers/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/runtime/invocation/routers/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/runtime/invocation/routers/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/runtime/invocation/routers/matlab.md), [PHP](https://docs.zeroc.com/ice/3.8/runtime/invocation/routers/php.md), [Python](https://docs.zeroc.com/ice/3.8/runtime/invocation/routers/python.md), [Swift](https://docs.zeroc.com/ice/3.8/runtime/invocation/routers/swift.md).

A *router* is an Ice object that forwards requests between clients and servers. On this page, the client is the application that connects to the router, and the server is the application the router forwards to, whichever of them sends a request. A proxy configured to use a router is a *routed proxy*: Ice sends its requests to the router, which forwards them to the target server. Ice connects to the router rather than to the endpoints of the routed proxy, and typically opens a single connection to a router for all the routed proxies that use it.

A router implements the `Ice::Router` interface. Ice includes two routers:

- [Glacier2](https://docs.zeroc.com/ice/3.8/services/glacier2.md) forwards the requests of authenticated clients to servers on another network, typically behind a firewall, and forwards callbacks to these clients over their existing connections. It finds the target of each request by its identity, so the objects that a client reaches through Glacier2 need [unique identities](https://docs.zeroc.com/ice/3.8/runtime/object-identity/ruby.md).
- [IceBridge](https://docs.zeroc.com/ice/3.8/services/icebridge.md) forwards requests to a single target server that the clients cannot reach directly, for example because they do not support its transport.

## Creating Routed Proxies

A communicator can have a default router. Every proxy this communicator creates, from a string, from a property, or by unmarshaling a proxy returned by an operation, is a routed proxy that uses this router. The [Ice.Default.Router](https://docs.zeroc.com/ice/3.8/property-reference/ice-default-properties/ruby.md#ice.default.router) property sets the default router; the value is a proxy for the router:

```config
Ice.Default.Router=Glacier2/router:tcp -h routerhost -p 4063
```

`setDefaultRouter` on the communicator sets the default router of the proxies created afterwards, and `getDefaultRouter` returns it.

The `ice_router` proxy factory method returns a routed proxy:

```ruby
router = Ice::RouterPrx.new(...)
greeter = VisitorCenter::GreeterPrx.new(...) # normal proxy
routedGreeter = greeter.ice_router(router)
```

The [Router](https://docs.zeroc.com/ice/3.8/property-reference/proxy-properties/ruby.md#name.router) proxy property sets the router of the proxy that `propertyToProxy` creates:

```config
MyProxy.Router=Glacier2/router:tcp -h routerhost -p 4063
```

## See Also

- [Glacier2](https://docs.zeroc.com/ice/3.8/services/glacier2.md)
- [IceBridge](https://docs.zeroc.com/ice/3.8/services/icebridge.md)
