4. If the complex number $z$ satisfies: $\frac{z-3 \mathrm{i}}{z+\mathrm{i}}$ is a negative real number ( $\mathrm{i}$ is the imaginary unit), $\frac{z-3}{z+1}$ is a pure imaginary number, then the value of $z$ is . $\qquad$
$$
\begin{array}{l}
\text { Let } z=a+b \mathrm{i}(a, b \in \mathbf{R}) \text {, then } \frac{z-3 \mathrm{i}}{z+\mathrm{i}}=\frac{a+(b-3) \mathrm{i}}{a+(b+1) \mathrm{i}}=\frac{[a+(b-3) \mathrm{i}][a-(b+1) \mathrm{i}]}{a^{2}+(b+1)^{2}}, \\
\frac{z-3}{z+1}=\frac{(a-3)+b \mathrm{i}}{(a+1)+b \mathrm{i}}=\frac{[(a-3)+b \mathrm{i}][(a+1)-b \mathrm{i}]}{(a+1)^{2}+b^{2}} . \\
\text { Therefore }\left\{\begin{array} { l } 
{ - a ( b - 1 ) + a ( b - 3 ) = 0 , } \\
{ ( a - 3 ) ( a + 1 ) + b ^ { 2 } = 0 }
\end{array} \Rightarrow \left\{\begin{array}{l}
a=0, \\
b^{2}=3,
\end{array} \text { substituting into } a^{2}+(b-3)(b+1)<0\right.\right. \\
\Rightarrow b=\sqrt{3} \text {. Thus } z=\sqrt{3} \mathrm{i} .
\end{array}
$$